updates custom error handler to fix issue with response code being sent back