Skip to content

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

@Startouf

Description

@Startouf

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions