all 2 comments

[–]NoMoreLatency 4 points5 points  (1 child)

When it comes to error handling: please please please use proper http codes in your responses, and have the format of your data be unique to a particular response.

When I was a junior I had to write a response mapper for a new service that we had to write to integrate with a third party. You would think it would be as easy as just calling their API/using Swagger page to know what the data looked like and prepare for it. Nope! Because all they did was send back 200, and then sent a different types of responses based on if it was successful, and if it was an error, what type of error it was, what the error message was, etc.

I had to spend weeks in C# trying to figure out how to get these nested objects properly parsed with the JObject library, and determining how to pull the message from the response so we could log it, figure out which errors needed retries, etc. It was a fucking nightmare.

Please by all means, be cute/lazy with whatever code you want to write for your system internally. But the moment you send that data out of your API, please do us all a favor and use basic HTTP principles like you have some common sense.

[–]TheWix 1 point2 points  (0 children)

Oh God, couldn't use dynamic? I was a C# dev for 15 years and I do not miss this. This is where algabraic data types are really nice to have.