1

I am building a REST API using Laravel framework and the Dingo API library. Everything works well except that I don't know how I can customize the default error handler when exception happens.

For example, when my code run error, the response is simply this:

{
     "message": "Error",
     "status_code": 500
}

How can I change this response to my own format?

D0n9X1n
  • 2,114
  • 1
  • 14
  • 17

1 Answers1

2
  • edit the errorFormat in config/api.php as you want.

    'errorFormat' => [
        'message' => ':message',
        'errors' => ':errors',
        'code' => 0,
        'status_code' => ':status_code',
        'result' => ':errors',
        'debug' => ':debug',
    ],

sun
  • 43
  • 1
  • 3