capture the status code before trying execution of the handler

This will prevent an exception at line 172 id self.handler_500 is None