On my project, I’ve spent the last week assigned to “error recovery” in the application – so far I’ve made dashboards for remote logging, but at first, I struggled with the second part of that statement: recovery.
How do I recover from something I haven’t seen? I’d be curious to see what other people’s strategy is for this, but my strategy has been to play the “What if?” game.
What if [BLANK]?
What if I get a 200 response, but the array of items is empty? What if a user does XYZ? What if I send a cr&3^$zy string to a service on accident? How do I prevent myself from sending a C*63JRzy string to a service?
Luckily, this is exactly the kind of thing TDD is good for, since I can write out my expectations, and with my test runner chugging along, see the results (and how they differ).
Expected ".error-message" but got "ICANHASCHEEZBURGER"
No idea if I’m doing this “right,” but it’s causing some interesting questions, and at least gets me some percentage of the way “there,” especially when dealing with external services and APIs where I have little to no documentation on what happens when things go wrong.