Skip to content

Cannot render custom error code meta.code through register_exception #20

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

Open
Startouf opened this issue Aug 16, 2018 · 1 comment
Open

Comments

@Startouf
Copy link

Some time ago we added automatically a meta.code when there were validation errors on the model, using the symbol of the error (with ActiveModel > 5).

We ran into cases where it did not feel right to add validation errors, but it was more relevant to raise an error in the service and rescue the error in the json:api controller via register_exception. But adding the meta there does not work

# Does not work :
register_exception FooError, status: 409, code: :already_performed_the_action_in_last_24h
register_exception FooError, status: 409, meta: { code: :already_performed_the_action_in_last_24h }

It would be great if the register_exception class method allowed passing a meta or code value that would be merged in the exception meta (rather than having to write a custom Custom Exception Handler)

@richmolj
Copy link
Contributor

Well said, I absolutely agree. Is this something you could submit a PR for? The only thing I'd change is make meta a proc.

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

No branches or pull requests

2 participants