Error Handling

Return an error from your handler to trigger a 500 response.

Return an Error

return nil, errors.New("something went wrong")

If you return an error, Barry will send:

  • Status code: 500
  • Response body: Server error: something went wrong

To intentionally return a 404, use:

return nil, core.ErrNotFound

This will return a proper 404 Not Found response with the correct status code.