setting response body on error not in debug mode and cleanup