Skip to content

Commit 7c4fe27

Browse files
committed
Clarified error format and handling.
1 parent 316d863 commit 7c4fe27

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

README.markdown

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

7676
## Exception Handling
7777

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:
78+
Grape can be told to rescue all exceptions and instead return them in text or json formats.
8179

8280
class Twitter::API < Grape::API
83-
rescue_from ArgumentError, NotImplementedError # :all for all errors
81+
rescue_from :all
82+
end
83+
84+
You can also rescue specific exceptions.
85+
86+
class Twitter::API < Grape::API
87+
rescue_from ArgumentError, NotImplementedError
88+
end
89+
90+
The error format can be specified using `error_format`. Available formats are `:json` and `:txt` (default).
91+
92+
class Twitter::API < Grape::API
93+
error_format :json
8494
end
8595

8696
## Note on Patches/Pull Requests

0 commit comments

Comments
 (0)