set status code to 500 if there is an error