specialtactics / laravel-api-boilerplate

Laravel API Boilerplate | Quickly build quality API products!
MIT License
491 stars 95 forks source link

display errors #16

Closed leandroruel closed 5 years ago

leandroruel commented 5 years ago

how i should return error messages it has anything documented about that? like, i'm doing a function to return followers and in my UserController i return just:

{
 "error": "you can't follow yourself"
}

any pattern?

specialtactics commented 5 years ago

Hi @leandroruel

Basically just throw the relevant http exception with whatever message you want. There are many HTTP exceptions in Symphony's http kernel, and some more in Dingo.

Have a look at boilerplate code, there are plenty of examples in the controllers.

leandroruel commented 5 years ago

thank you, found it! shared this repo in my twitter too

specialtactics commented 5 years ago

Awesome, thanks @leandroruel ! :smile: