mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 23:51:25 +08:00
change: update capture exception
This commit is contained in:
@@ -48,14 +48,14 @@ def get_req_resp_record(resp_obj: Response) -> ReqRespData:
|
|||||||
if request_body is not None:
|
if request_body is not None:
|
||||||
try:
|
try:
|
||||||
request_body = json.loads(request_body)
|
request_body = json.loads(request_body)
|
||||||
except json.JSONDecodeError as ex:
|
except json.JSONDecodeError:
|
||||||
# str: a=1&b=2
|
# str: a=1&b=2
|
||||||
pass
|
pass
|
||||||
except UnicodeDecodeError as ex:
|
except UnicodeDecodeError as ex:
|
||||||
# bytes/bytearray: request body in protobuf
|
# bytes/bytearray: request body in protobuf
|
||||||
capture_exception(ex)
|
capture_exception(ex)
|
||||||
except TypeError as ex:
|
except TypeError as ex:
|
||||||
# neither str nor bytes/bytearray
|
# neither str nor bytes/bytearray, e.g. <MultipartEncoder>
|
||||||
capture_exception(ex)
|
capture_exception(ex)
|
||||||
|
|
||||||
request_content_type = lower_dict_keys(request_headers).get("content-type")
|
request_content_type = lower_dict_keys(request_headers).get("content-type")
|
||||||
|
|||||||
@@ -167,8 +167,8 @@ class HarParser(object):
|
|||||||
try:
|
try:
|
||||||
post_data = json.loads(post_data)
|
post_data = json.loads(post_data)
|
||||||
request_data_key = "json"
|
request_data_key = "json"
|
||||||
except JSONDecodeError as ex:
|
except JSONDecodeError:
|
||||||
capture_exception(ex)
|
pass
|
||||||
elif mimeType.startswith("application/x-www-form-urlencoded"):
|
elif mimeType.startswith("application/x-www-form-urlencoded"):
|
||||||
post_data = utils.convert_x_www_form_urlencoded_to_dict(post_data)
|
post_data = utils.convert_x_www_form_urlencoded_to_dict(post_data)
|
||||||
else:
|
else:
|
||||||
@@ -238,16 +238,12 @@ class HarParser(object):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
resp_content_json = json.loads(content)
|
resp_content_json = json.loads(content)
|
||||||
except JSONDecodeError as ex:
|
except JSONDecodeError:
|
||||||
capture_exception(ex)
|
logger.warning(f"response content can not be loaded as json: {content}")
|
||||||
logger.warning(
|
|
||||||
"response content can not be loaded as json: {}".format(
|
|
||||||
content.encode("utf-8")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
if not isinstance(resp_content_json, dict):
|
if not isinstance(resp_content_json, dict):
|
||||||
|
# e.g. ['a', 'b']
|
||||||
return
|
return
|
||||||
|
|
||||||
for key, value in resp_content_json.items():
|
for key, value in resp_content_json.items():
|
||||||
|
|||||||
Reference in New Issue
Block a user