File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,27 @@ Also it can have `meta` attribute when there is additional info. For example for
6969For ` ValidationApiException ` , meta attribute has ` errors ` object that contains validations errors.
7070Every attribute of this object is a name of a request parameter to validate to and value is an array of errors with description.
7171
72+ #### Customization
73+
74+ You can customize errors APU response by overriding ` formatApiResponse ` method in your ExceptionsHandler.
75+
76+ For example if you want to put everything under ` error ` attribute, you can do it like this:
77+
78+ ``` php
79+ /**
80+ * Format error message for API response.
81+ *
82+ * @param ApiException $exception
83+ * @return mixed
84+ */
85+ protected function formatApiResponse(ApiException $exception)
86+ {
87+ return [
88+ 'error' => $exception->toArray(),
89+ ];
90+ }
91+ ```
92+
7293### Views
7394
7495Since version 0.3.0 for Laravel 5.3 package can also return html view of the error, if ` Accept ` header not equals ` application/json ` .
You can’t perform that action at this time.
0 commit comments