Skip to content
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

Refactor errors, adding section for Message Function Errors #774

Merged
merged 10 commits into from
May 13, 2024

Conversation

eemeli
Copy link
Collaborator

@eemeli eemeli commented Apr 23, 2024

CC @mradbourne, who should be added to the repo.

As discussed yesterday, our error categories could be improved. This PR effects the categorisation we discussed, with "Message Function Error" introduced as the supertype of the errors that are coming from a custom function and "Invalid Expression" renamed to avoid its re-definition of what "valid" means in an MF2 context.

This and #767 should not be considered as blockers for each other. Instead, we'll need a fixup PR after both of these land adding the kebab-case error codes to errors.md and updating the ones used in the tests.

@eemeli eemeli added registry formatting errors Issues related to the errors section of the spec labels Apr 23, 2024
Copy link
Member

@aphillips aphillips left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good start.

spec/errors.md Show resolved Hide resolved
spec/errors.md Show resolved Hide resolved
spec/errors.md Outdated Show resolved Hide resolved
spec/errors.md Outdated Show resolved Hide resolved
spec/errors.md Show resolved Hide resolved
spec/errors.md Outdated Show resolved Hide resolved
spec/formatting.md Outdated Show resolved Hide resolved
spec/formatting.md Outdated Show resolved Hide resolved
spec/formatting.md Outdated Show resolved Hide resolved
spec/registry.md Show resolved Hide resolved
Co-authored-by: Addison Phillips <[email protected]>
spec/errors.md Outdated Show resolved Hide resolved
spec/errors.md Outdated Show resolved Hide resolved
spec/errors.md Outdated Show resolved Hide resolved
spec/formatting.md Outdated Show resolved Hide resolved
Copy link
Member

@aphillips aphillips left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One change proposed, otherwise looks good.

spec/errors.md Outdated Show resolved Hide resolved
spec/errors.md Outdated Show resolved Hide resolved
Comment on lines +258 to +259
A **_<dfn>Message Function Error</dfn>_** is any error that occurs
when calling a message function implementation
Copy link
Collaborator

Choose a reason for hiding this comment

The 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).

spec/errors.md Outdated Show resolved Hide resolved
spec/errors.md Outdated Show resolved Hide resolved
spec/errors.md Outdated Show resolved Hide resolved
spec/errors.md Outdated Show resolved Hide resolved
Co-authored-by: Richard Gibson <[email protected]>
Co-authored-by: Addison Phillips <[email protected]>
spec/errors.md Show resolved Hide resolved
spec/errors.md Outdated Show resolved Hide resolved
@eemeli
Copy link
Collaborator Author

eemeli commented May 7, 2024

As discussed yesterday and following @gibson042's suggestion in #774 (comment), I've now dropped the Selection Error and Formatting Error types.

However, while doing so, I noticed that Selection Error was used in two places by our current spec:

  1. During pattern selection, for selectors that don't support selection. So I added Bad Selector for this, as a resolution error.
  2. In the :number MatchSelectorKeys() call, for variant keys that aren't numbers or plural categories. So I added Bad Variant Key for this, as a message value error.

In total, this means that two somewhat generic error types are replaced by two very specific ones.

I also think we should consider adding something like Bad Formatter for placeholders that use a selection-only function annotation. As with Bad Selector, that error isn't really emitted by the function implementation, but by the MF2 implementation. But we can handle this as a separate next step.

@eemeli eemeli requested review from aphillips and gibson042 May 7, 2024 10:38
Copy link
Member

@aphillips aphillips left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Mostly editorial suggestions.

spec/errors.md Show resolved Hide resolved
spec/errors.md Show resolved Hide resolved
spec/errors.md Outdated Show resolved Hide resolved
spec/errors.md Show resolved Hide resolved
spec/errors.md Outdated Show resolved Hide resolved
spec/errors.md Outdated Show resolved Hide resolved
spec/errors.md Show resolved Hide resolved
Co-authored-by: Addison Phillips <[email protected]>
Copy link
Collaborator

@catamorphism catamorphism left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@eemeli eemeli requested a review from aphillips May 8, 2024 07:13
@aphillips aphillips merged commit f111102 into main May 13, 2024
1 check passed
@aphillips aphillips deleted the message-function-errors branch May 13, 2024 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
errors Issues related to the errors section of the spec formatting registry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants