I think I just spent like 3x as much time figuring out to handle errors properly instead of coding real functionality.

225 points Aggressive_Sherbet64 53 comments

And it was completely worth it.

Yes - boxing errors works for getting something that technically does the core functionality of what you care about (in my case I'm basically just writing a wrapper for OpenAI api calls). And yea I got something working, and I really could have left it that way with a bunch of really fugly "Box<dyn Error>"s all over the place (ew).

But but but something primal in me "NO! THAT'S THE DEVIL" so I ended up spending ages getting all my wrappers neatly tied up with the special errors that I wanted. And the code is so much better now and I caught a couple of places where I could have had a panic that would have brought my whole server down. Plus I found a stupid case where one api call failing would cause all the rest of them to fail. Unacceptable!

DON'T FORGET TO HANDLE YOUR ERRORS!