From 7ad70c7344fbc09a356a2b9cb76d411c9f3452d8 Mon Sep 17 00:00:00 2001 From: Jason Karns Date: Wed, 25 May 2022 08:14:05 -0400 Subject: [PATCH 1/3] Update error-handling.md Text refers to RescueRegistry gem but the code snippet is subclassing GraphitiErrors. I assume the code snippet is just out of date? --- guides/concepts/error-handling.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/concepts/error-handling.md b/guides/concepts/error-handling.md index 974ed9b..1f9154d 100644 --- a/guides/concepts/error-handling.md +++ b/guides/concepts/error-handling.md @@ -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 # self.exception accessible within all instance methods def status_code From 9b42aaa55df3cdbe2c8fca6fc83a23614073bfad Mon Sep 17 00:00:00 2001 From: Jason Karns Date: Wed, 25 May 2022 14:31:45 -0400 Subject: [PATCH 2/3] Document `detail` option instead of `message` rescue_registry gem prefers :detail option over :message. --- guides/concepts/error-handling.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/guides/concepts/error-handling.md b/guides/concepts/error-handling.md index 1f9154d..b383072 100644 --- a/guides/concepts/error-handling.md +++ b/guides/concepts/error-handling.md @@ -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 %} @@ -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). From 01ad8509fb883f2ea1eeb9f2932c400dbeeecff1 Mon Sep 17 00:00:00 2001 From: Jason Karns Date: Wed, 25 May 2022 14:34:55 -0400 Subject: [PATCH 3/3] Recommend graphiti-rails' exception handler If an app is using graphiti-rails, it is presumably preferable to subclass `Graphiti::Rails::ExceptionHandler` instead of `RescueRegistry::ExceptionHandler` --- guides/concepts/error-handling.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/concepts/error-handling.md b/guides/concepts/error-handling.md index b383072..3c692b4 100644 --- a/guides/concepts/error-handling.md +++ b/guides/concepts/error-handling.md @@ -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 < RescueRegistry::ExceptionHandler +class MyCustomHandler < RescueRegistry::ExceptionHandler # prefer < Graphiti::Rails::ExceptionHandler if using graphiti-rails # self.exception accessible within all instance methods def status_code pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy