Fix error handling in case of empty body (return HTTP response code in exception).