Add error checking when setting exception handler

milestone2