-
-
Notifications
You must be signed in to change notification settings - Fork 35
Refactor errors, adding section for Message Function Errors #774
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
fa60b0f
Refactor errors, adding section for Message Function Errors
eemeli 235767c
Apply suggestions from code review
eemeli 6764976
Apply suggestions from code review
eemeli a469602
Drop exemplary text from Formatting Error description
eemeli 04d7aa5
Drop "Bad Expression", add SHOULD for letting functions pick their error
eemeli b76dc21
Use "appropriate" rather than "a" for Message Function Errors
eemeli 64f2bc5
Apply suggestions from code review
eemeli 5d263ff
Apply suggestions from code review
eemeli 3281162
Drop Selection & Formatting erorrs, add Bad Selector & Bad Variant Key
eemeli 4ab0e94
Apply suggestions from code review
eemeli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,10 +16,10 @@ and MUST be emitted as soon as possible. | |
| The other error categories are only emitted during formatting, | ||
| but it might be possible to detect them with validation tools. | ||
|
|
||
| During selection, an _expression_ handler MUST only emit _Resolution Errors_ and _Selection Errors_. | ||
| During formatting, an _expression_ handler MUST only emit _Resolution Errors_ and _Formatting Errors_. | ||
| During selection and formatting, | ||
| _expression_ handlers MUST only emit _Message Function Errors_. | ||
eemeli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| _Resolution Errors_ and _Formatting Errors_ in _expressions_ that are not used | ||
| _Resolution Errors_ and _Message Function Errors_ in _expressions_ that are not used | ||
| in _pattern selection_ or _formatting_ MAY be ignored, | ||
| as they do not affect the output of the formatter. | ||
eemeli marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|
|
@@ -34,7 +34,7 @@ SHOULD prioritise _Syntax Errors_ and _Data Model Errors_ over others. | |
|
|
||
| When an error occurs within a _selector_, | ||
| the _selector_ MUST NOT match any _variant_ _key_ other than the catch-all `*` | ||
| and a _Resolution Error_ or a _Selection Error_ MUST be emitted. | ||
| and a _Resolution Error_ or a _Message Function Error_ MUST be emitted. | ||
aphillips marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ## Syntax Errors | ||
|
|
||
|
|
@@ -241,49 +241,71 @@ or for private implementation use that is not supported by the current implement | |
| > * {{The value is not one.}} | ||
| > ``` | ||
|
|
||
| ### Invalid Expression | ||
| ### Unsupported Statement | ||
|
|
||
| An **_<dfn>Unsupported Statement</dfn>_** error occurs when a message includes a _reserved statement_. | ||
|
|
||
| > For example, attempting to format this message | ||
| > would always result in an _Unsupported Statement_ error: | ||
| > | ||
| > ``` | ||
| > .some {|horse|} | ||
| > {{The message body}} | ||
| > ``` | ||
eemeli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| An **_<dfn>Invalid Expression</dfn>_** error occurs when a _message_ includes an _expression_ | ||
| whose implementation-defined internal requirements produce an error during _function resolution_ | ||
| or when a _function_ returns a value (such as `null`) that the implementation does not support. | ||
| ## Message Function Errors | ||
eemeli marked this conversation as resolved.
Show resolved
Hide resolved
aphillips marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| An **_<dfn>Operand Mismatch Error</dfn>_** is an _Invalid Expression_ error that occurs when | ||
| A **_<dfn>Message Function Error</dfn>_** is any error that occurs | ||
| when calling a message function implementation | ||
|
Comment on lines
+273
to
+274
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like this use of the singular, and would suggest that the previous part of this document be updated accordingly (but for consistency, I think similar phrasing should be used for all sections in this PR). |
||
| or which depend on validation associated with a specific function. | ||
eemeli marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Implementations SHOULD provide a way for custom functions to specify | ||
| which of the following errors ought to be emitted, | ||
| as well as allowing for other implementation-defined _Message Function Errors_. | ||
eemeli marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### Bad Operand | ||
aphillips marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| A **_<dfn>Bad Operand</dfn>_** error is an error that occurs when | ||
| an _operand_ provided to a _function_ during _function resolution_ does not match one of the | ||
| expected implementation-defined types for that function; | ||
| or in which a literal _operand_ value does not have the required format | ||
| and thus cannot be processed into one of the expected implementation-defined types | ||
| for that specific _function_. | ||
|
|
||
| > For example, the following _message_ produces an _Operand Mismatch Error_ | ||
| > (a type of _Invalid Expression_ error) | ||
| > For example, the following _message_ produces a _Bad Operand_ error | ||
| > because the literal `|horse|` does not match the production `number-literal`, | ||
| > which is a requirement of the function `:number` for its operand: | ||
| > | ||
| > ``` | ||
| > .local $horse = {horse :number} | ||
| > {{You have a {$horse}.}} | ||
| > ``` | ||
eemeli marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| > The following _message_ might produce an _Invalid Expression_ error if the | ||
| > the function `:function` threw an exception or otherwise emitted an error | ||
| > rather than returning a valid value: | ||
| >``` | ||
| > {{This has an invalid expression {$var :function} because it has a bug in it.}} | ||
| >``` | ||
|
|
||
| ### Unsupported Statement | ||
| ### Bad Option | ||
|
|
||
| An **_<dfn>Unsupported Statement</dfn>_** error occurs when a message includes a _reserved statement_. | ||
| A **_<dfn>Bad Option</dfn>_** error is an error that occurs when there is | ||
| an implementation-defined error with an _option_ or its value. | ||
| These might include: | ||
| - A required _option_ is missing. | ||
| - Mutually exclusive _options_ are supplied. | ||
| - An _option_ value provided to a _function_ during _function resolution_ | ||
| does not match one of the implementation-defined types for that _function_; | ||
eemeli marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| or in which the literal _option_ value does not have the required format | ||
| and thus cannot be processed into one of the expected | ||
| implementation-defined types for that specific _function_. | ||
| - Any other implementation-defined errors related to _options_. | ||
eemeli marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| > For example, attempting to format this message | ||
| > would always result in an _Unsupported Statement_ error: | ||
| > For example, the following _message_ might produce a _Bad Option_ error | ||
| > because the literal `foo` does not match the production `digit-size-option`, | ||
| > which is a requirement of the function `:number` for its `minimumFractionDigits` _option_: | ||
| > | ||
| > ``` | ||
| > .some {|horse|} | ||
| > {{The message body}} | ||
| > The answer is {42 :number minimumFractionDigits=foo}. | ||
| > ``` | ||
|
|
||
| ## Selection Errors | ||
| ### Selection Error | ||
|
|
||
| **_<dfn>Selection Errors</dfn>_** occur when message selection fails. | ||
| A **_<dfn>Selection Error</dfn>_** occurs when message selection fails. | ||
|
|
||
| > For example, attempting to format either of the following messages | ||
| > might result in a _Selection Error_ if done within a context that | ||
eemeli marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
@@ -302,11 +324,9 @@ An **_<dfn>Unsupported Statement</dfn>_** error occurs when a message includes a | |
| > * {{The value is not one.}} | ||
| > ``` | ||
|
|
||
| ## Formatting Errors | ||
| ### Formatting Error | ||
|
|
||
| **_<dfn>Formatting Errors</dfn>_** occur during the formatting of a resolved value, | ||
| for example when encountering a value with an unsupported type | ||
| or an internally inconsistent set of options. | ||
| A **_<dfn>Formatting Error</dfn>_** occurs during the formatting of a resolved value. | ||
|
|
||
| > For example, attempting to format any of the following messages | ||
| > might result in a _Formatting Error_ if done within a context that | ||
eemeli marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.