Fix bug in error handler functionality