Skip to content

Improve Jason.Encoder derive option errors - #204

Open
dl-alexandre wants to merge 1 commit into
michalmuskala:masterfrom
dl-alexandre:fix/improve-derive-option-errors
Open

Improve Jason.Encoder derive option errors#204
dl-alexandre wants to merge 1 commit into
michalmuskala:masterfrom
dl-alexandre:fix/improve-derive-option-errors

Conversation

@dl-alexandre

Copy link
Copy Markdown

Summary

  • reject unknown options passed when deriving Jason.Encoder
  • raise a compile-time ArgumentError listing the accepted :only and :except options
  • cover the invalid option case with a regression test

Fixes #183

This is a clean re-publication of #203 (the prior PR used a codex/ branch prefix which is not permitted for final contributions).

Validation

  • mix test test/encode_test.exs
  • mix test

Validate options passed to @derive {Jason.Encoder, ...} and raise a
clear ArgumentError for unknown keys (only :only and :except are
supported). Includes a test for the validation error.

This makes the "invalid option" experience consistent with the
documented API.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Better error message on invalid @derive Jason.Encoder options

1 participant