B
B
Bogdan2018-03-26 14:54:12
Ruby on Rails
Bogdan, 2018-03-26 14:54:12

Passing Errors With Api?

Hello. Tell me please. What is the best way to organize the transmission of business logic errors. For example, if the user is not authenticated, or not found at all, or there are no access rights ... well, there may be a lot of conditions? Send code in response body:

200 { status: false, error: user not found', code: 'свой код ошибки' }

or
Or send an error in the http status code , but the number of codes there is not very large to cover all possible errors in the application? Interested in the architectural aspect
Thank you

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2018-03-26
@sergey-gornostaev

Respond with the appropriate http code and return a string or json with the detailed error text in the body.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question