Fix error handler bug