Writing · Tag
error handling
Posts
A REST error taxonomy: frozen codes and three shapes
Code structure & architectureOct 13, 20264 min
If your API can return an error in fifty different JSON shapes, your clients handle none of them and everyone ends up parsing a message string with a regex. So pick a small fixed set of shapes, give every error a stable code, and never let an endpoint invent its own. This is the taxonomy I put on every API, and it is the other half of the lathos post from last time.
Read the post
Behaviour-driven error handling: lathos and one global handler
Code structure & architectureSep 29, 20264 min
An error is a not-found because it says it is, not because of what type it happens to be. That one idea is what lets me delete the pile of errors.Is blocks out of every handler and put the whole HTTP-status decision in a single place. Here is how it hangs together, with the library I use for it, lathos.
Read the post