Stupid Coder Tricks: Debugging Exception Handlers


This is my favorite utility when monkeying around with (ie, testing) generic exception-handling code:

class Poop : Exception { this() { // It's a bird! It's a plane! No, it's... super("POOP!"); } } @property auto POOP() { return new Poop(); }

As if you haven't already figured out this utility's obvious benefit:

throw POOP;

Of course, if you're using a language that allows any old type of crap to be thrown (which I don't ordinarily prefer), it's even easier:

// Cut the crap and just throw it! throw "POOP!";

Leave a comment

Captcha