Use HTTPError exception to catch http status code.