make sure to write out the 500 content in the default error case
simplify failure handling