Use custom error classes instead of generic errors#1701
Merged
joelhawksley merged 34 commits intomainfrom Apr 4, 2023
Merged
Conversation
…xtCalledBeforeRenderError`.
…textCalledBeforeRenderError`, removing `ViewContextCalledBeforeRenderError`.
…of `ArgumentError`.
…f `ArgumentError`.
…d of `ArgumentError`.
camertron
approved these changes
Apr 3, 2023
Contributor
camertron
left a comment
There was a problem hiding this comment.
Oh wow this is awesome! 🎉
| @path = ::File.realpath(params.permit(:file)[:file], base_path) | ||
| unless @path.start_with?(base_path) | ||
| raise ArgumentError, "Invalid file path" | ||
| raise ViewComponent::SystemTestControllerNefariousPathError |
Comment on lines
+9
to
+12
| MESSAGE = | ||
| "It looks like a block was provided after calling `with_content` on COMPONENT, " \ | ||
| "which means that ViewComponent doesn't know which content to use.\n\n" \ | ||
| "To fix this issue, use either `with_content` or a block." |
Contributor
There was a problem hiding this comment.
Would these look better as squiggly heredocs?
Suggested change
| MESSAGE = | |
| "It looks like a block was provided after calling `with_content` on COMPONENT, " \ | |
| "which means that ViewComponent doesn't know which content to use.\n\n" \ | |
| "To fix this issue, use either `with_content` or a block." | |
| MESSAGE = <<~MESSAGE | |
| It looks like a block was provided after calling `with_content` on COMPONENT, | |
| which means that ViewComponent doesn't know which content to use. | |
| To fix this issue, use either `with_content` or a block. | |
| MESSAGE |
Member
Author
There was a problem hiding this comment.
I'm not sure these lines are equivalent, though? I'm trying to have the first sentence of the output be a single line of text.
Member
Author
There was a problem hiding this comment.
Confirmed in the console: => "It looks like a block was provided after calling with_content on COMPONENT,\n
claudiob
pushed a commit
to claudiob/view_component
that referenced
this pull request
Dec 22, 2023
* BREAKING: Use `HelpersCalledBeforeRenderError` in place of `ViewContextCalledBeforeRenderError`. * BREAKING: Use `TranslateCalledBeforeRenderError` in place of `ViewContextCalledBeforeRenderError`, removing `ViewContextCalledBeforeRenderError`. * BREAKING: Raise `NilWithContentError` instead of `ArgumentError`. * BREAKING: Raise `ViewComponent::ReservedPluralSlotNameError` instead of `ArgumentError`. * BREAKING: Raise `ViewComponent::InvalidSlotDefinitionError` instead of `ArgumentError`. * BREAKING: Raise `ViewComponent::ContentSlotNameError` instead of `ArgumentError`. * BREAKING: Raise `ViewComponent::ReservedSingularSlotNameError` instead of `ArgumentError`. * BREAKING: Raise `ViewComponent::RedefinedSlotError` instead of `ArgumentError`. * let's be real these are just going to be squashed * finish slotable errors * system test controller errors * add preview helper custom errors * add DuplicateContentError * add custom error classes for collections * ReservedParameterError instead of generic class * InvalidCollectionArgumentError instead of generic error * allow components to redefine with_content * fix warning * use MultipleInlineTemplatesError * raise MissingPreviewTemplateError * move TemplateError to Errors module * raise DuplicateSlotContentError * remove untested and likely unused error case in tests * syntax * Revert "remove untested and likely unused error case in tests" This reverts commit 00cdb0c. * fix failing test * fix failing test * lints * thank you Vale * fix failing test * capitalization * mdlint * fix failing test
claudiob
pushed a commit
to claudiob/view_component
that referenced
this pull request
Jan 3, 2024
* BREAKING: Use `HelpersCalledBeforeRenderError` in place of `ViewContextCalledBeforeRenderError`. * BREAKING: Use `TranslateCalledBeforeRenderError` in place of `ViewContextCalledBeforeRenderError`, removing `ViewContextCalledBeforeRenderError`. * BREAKING: Raise `NilWithContentError` instead of `ArgumentError`. * BREAKING: Raise `ViewComponent::ReservedPluralSlotNameError` instead of `ArgumentError`. * BREAKING: Raise `ViewComponent::InvalidSlotDefinitionError` instead of `ArgumentError`. * BREAKING: Raise `ViewComponent::ContentSlotNameError` instead of `ArgumentError`. * BREAKING: Raise `ViewComponent::ReservedSingularSlotNameError` instead of `ArgumentError`. * BREAKING: Raise `ViewComponent::RedefinedSlotError` instead of `ArgumentError`. * let's be real these are just going to be squashed * finish slotable errors * system test controller errors * add preview helper custom errors * add DuplicateContentError * add custom error classes for collections * ReservedParameterError instead of generic class * InvalidCollectionArgumentError instead of generic error * allow components to redefine with_content * fix warning * use MultipleInlineTemplatesError * raise MissingPreviewTemplateError * move TemplateError to Errors module * raise DuplicateSlotContentError * remove untested and likely unused error case in tests * syntax * Revert "remove untested and likely unused error case in tests" This reverts commit 00cdb0c. * fix failing test * fix failing test * lints * thank you Vale * fix failing test * capitalization * mdlint * fix failing test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What are you trying to accomplish?
The goal of this PR is to add all of our error messages to our docs. In order to do so, I moved all of our errors to an
Errorsmodule and had YARD look for classes ending inErrorthat have aMESSAGEconstant.I also cleaned up a few errors that should have been removed previously. I'll follow up with a review of our error messages themselves.
What do y'all think of the names for these errors?