File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed
Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments