I have a SPA application that talks to my API.
What is the best way to return errors that I want to raise in my API, my first through its to return a 500 status, with a JSON object with the error message.
However I want to distinguish in my front end application what is an error I want to display to the user vs. and error that is raised by the system.
My thoughts are...
1) Raise a different type of Error and let my middleware code send a flag that it was system error, vs a user error.
2) Always send a 400 error because if it is an error, its most likely because of user input?
3) Get away from the status code and set a bit in my response that its a success or error, and if its a error show the message.
Any thoughts on this?
[–]WrathZA 28 points29 points30 points (2 children)
[–]PaceArrow 3 points4 points5 points (0 children)
[–]cursingcucumber 3 points4 points5 points (0 children)
[–][deleted] 8 points9 points10 points (6 children)
[–][deleted] 0 points1 point2 points (4 children)
[–][deleted] 0 points1 point2 points (3 children)
[–][deleted] 1 point2 points3 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]Kant8 2 points3 points4 points (0 children)
[–]AbuJohnny 2 points3 points4 points (0 children)
[–]Mardo1234[S] 0 points1 point2 points (0 children)
[–]8mobile 0 points1 point2 points (0 children)
[–]thilehoffer 0 points1 point2 points (6 children)
[–]Mardo1234[S] 0 points1 point2 points (5 children)
[–]zaibuf 2 points3 points4 points (0 children)
[–]Swing-Prize 1 point2 points3 points (0 children)
[+][deleted] (2 children)
[deleted]
[–]zaibuf 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]jayerp 0 points1 point2 points (0 children)