Fix error handler for 500 statuses