Skip to content

Commit 93732a3

Browse files
author
Michael Bleigh
committed
Amend README
1 parent 15803ae commit 93732a3

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

README.markdown

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,12 @@ You can also return JSON formatted objects explicitly by raising error! and pass
7575

7676
## Exception Handling
7777

78-
By default Grape does not catch all unexpected exceptions. This means that the web server will handle the error and render the default error page as a result. It is possible to trap all exceptions by setting `rescue_all_errors true` instead. You may change the error format to JSON by using `error_format :json` and set the default error status to 200 with `default_error_status 200`. You may also include the complete backtrace of the exception with `rescue_with_backtrace true` either as text (for the :txt format) or as a :backtrace field in the json (for the :json format).
78+
Grape can be told to rescue certain (or all) exceptions in your
79+
application and instead display them in text or json form. To do this,
80+
you simply use the `rescue_from` method inside your API declaration:
7981

8082
class Twitter::API < Grape::API
81-
rescue_all_errors true
82-
rescue_with_backtrace true
83-
error_format :json
84-
default_error_status 200
85-
86-
# api methods
83+
rescue_from ArgumentError, NotImplementedError # :all for all errors
8784
end
8885

8986
## Note on Patches/Pull Requests

0 commit comments

Comments
 (0)