Skip to content

Configure exception class whitelist to be reraised by operations processors.#290

Merged
lgebhardt merged 2 commits intoJSONAPI-Resources:masterfrom
togglepro:exception_whitelist
Jul 6, 2015
Merged

Configure exception class whitelist to be reraised by operations processors.#290
lgebhardt merged 2 commits intoJSONAPI-Resources:masterfrom
togglepro:exception_whitelist

Conversation

@barelyknown
Copy link
Copy Markdown
Collaborator

For example, if you use Pundit for authorization, you might
raise a Pundit::NotAuthorizedError at some point during operations
processing. If you want to use Rails' rescue_from macro to
catch this error and render a 403 status code, you should add
the Pundit::NotAuthorizedError to the exception_class_whitelist.

JSONAPI.configuration.exception_class_whitelist = [Pundit::NotAuthorizedError]

…essors.

For example, if you use Pundit for authorization, you might
raise a Pundit::NotAuthorizedError at some point during operations
processing. If you want to use Rails' `rescue_from` macro to
catch this error and render a 403 status code, you should add
the `Pundit::NotAuthorizedError` to the `exception_class_whitelist`.

`JSONAPI.configuration.exception_class_whitelist = [Pundit::NotAuthorizedError]`
lgebhardt added a commit that referenced this pull request Jul 6, 2015
Configure exception class whitelist to be reraised by operations processors.
@lgebhardt lgebhardt merged commit 9b5d171 into JSONAPI-Resources:master Jul 6, 2015
@lgebhardt
Copy link
Copy Markdown
Contributor

Thanks! This adds some nice flexibility that was inadvertently lost with the InternalServer error change.

@barelyknown
Copy link
Copy Markdown
Collaborator Author

I agree. It's nice to gracefully rescue internal server errors, but having the option to raise/rescue some classes is pretty important in my experience.

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.

2 participants