It's hard when you hit an endpoint that hits another endpoint, because technically the first request IS a 200. No right or wrong way as long as they are consistent and document it clearly imo
I my experience you then send a different error code to help developers know that right away. Really if there is nothing the developer could do it should be a 500 server error. The server did in fact error.
If the developer should have done something different then translate it to an appropriate code, 400 bad request or something
After working few years on a complex web application, I am starting to feel this style.
Doing RESTful APIs for anything else than dead simple CRUD is pain.
It's similar to how I now often avoid throwing errors in my code, and instead return a 'results' object that could potentially have an error or a success. It often forces you to test and think about the non happy path more thoroughly.
Exceptions actually have a huge performance hit, you should only use them in a HALT EVERYTHING IMMEDIATELY situations and never in anything that could be called repeatedly.
We have refactored few of those to be 10-100 times faster by just returning success: false instead of throwing and catching exceptions.
The quality of Microsoft APIs is legendary... if you just take a minute to study win32, you will be always glad that those webserver responses are the kind of shit you have to deal with.
But to be fair, this looks exactly like a well designed API that somebody pushed behind a corporate firewall.
What don't you like about graphql error handling? Whenever I've made a graphql api, I use the default errors as unhandled/system errors and payloads return handled error types.
It's a bit more boilerplate to wire up, but I find it smooth to build and use
Yeah, typical on .net too. I just have a middleware and turn it into proper REST. Though all the error messages are usually like 'something went wrong'.
There's a video somewhere by someone... Returning a blank document instead of an error code is sometimes a QoS decision. Clients won't make a new request without the user intervention, so whatever resource that's bottlenecked has time to catch up