You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,7 @@
2
2
3
3
#### Features
4
4
5
+
*[#1754](https://github.com/ruby-grape/grape/pull/1754): Added `rescue_from :exception` to truly rescue from all exceptions - [@jelkster](https://github.com/jelkster).
Copy file name to clipboardExpand all lines: README.md
+9-1
Original file line number
Diff line number
Diff line change
@@ -2083,6 +2083,14 @@ end
2083
2083
This mimics [default `rescue` behaviour](https://ruby-doc.org/core/StandardError.html) when an exception type is not provided.
2084
2084
Any other exception should be rescued explicitly, see [below](#exceptions-that-should-be-rescued-explicitly).
2085
2085
2086
+
In the event you want to truly rescue all exceptions, this can be done.
2087
+
2088
+
```ruby
2089
+
classTwitter::API < Grape::API
2090
+
rescue_from :exception
2091
+
end
2092
+
```
2093
+
2086
2094
Grape can also rescue from all exceptions and still use the built-in exception handing.
2087
2095
This will give the same behavior as `rescue_from :all` with the addition that Grape will use the exception handling defined by all Exception classes that inherit `Grape::Exceptions::Base`.
2088
2096
@@ -2289,7 +2297,7 @@ Here `'inner'` will be result of handling occured `ArgumentError`.
2289
2297
2290
2298
Any exception that is not subclass of `StandardError` should be rescued explicitly.
2291
2299
Usually it is not a case for an application logic as such errors point to problems in Ruby runtime.
2292
-
This is following [standard recomendations for exceptions handling](https://ruby-doc.org/core/Exception.html).
2300
+
This is following [standard recommendations for exceptions handling](https://ruby-doc.org/core/Exception.html).
0 commit comments