Skip to content

Update error-handling.md #45

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
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions guides/concepts/error-handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ code. For other errors, we may want to render a helpful error message:
class ApplicationController < ActionController::API
register_exception NotAuthorized, status: 403
register_exception ShipmentDelayed,
message: ->(e) { "Contact us at 123-456-7899" }
detail: ->(e) { "Contact us at 123-456-7899" }
# ... code ...
end
{% endhighlight %}
Expand Down Expand Up @@ -111,8 +111,8 @@ Additional options:
register_exception Errors::NotAuthorized,
status: 403,
title: "You cannot perform this action",
message: true, # render the raw error message
message: ->(error) { "Invalid Action" } # message via proc
detail: :exception, # render the raw error message
detail: ->(error) { "Invalid Action" } # message via proc
{% endhighlight %}

[See full documentation in the RescueRegistry README](https://github.com/wagenet/rescue_registry).
Expand All @@ -130,7 +130,7 @@ end
The final option `register_exception` accepts is `handler`. Here you can inject your own error handling class that customize `RescueRegistry::ExceptionHandler`. For example:

{% highlight ruby %}
class MyCustomHandler < GraphitiErrors::ExceptionHandler
class MyCustomHandler < RescueRegistry::ExceptionHandler # prefer < Graphiti::Rails::ExceptionHandler if using graphiti-rails
# self.exception accessible within all instance methods

def status_code
Expand Down