Updated global error handler