Catch HTTP exceptions and format response object