mirror of
https://github.com/kevin1024/vcrpy.git
synced 2025-12-09 09:13:23 +00:00
Add Exception when JSON Serializing Binary Data
Since I can't think of a good way to deal with this, let's just give a nice error message to point people in the right direction. Closes #51
This commit is contained in:
@@ -27,4 +27,12 @@ def serialize(cassette_dict):
|
||||
cassette_dict['requests'],
|
||||
cassette_dict['responses']
|
||||
)])
|
||||
return json.dumps(data, indent=4, default=_json_default)
|
||||
try:
|
||||
return json.dumps(data, indent=4, default=_json_default)
|
||||
except UnicodeDecodeError as e:
|
||||
raise UnicodeDecodeError(
|
||||
"Error serializing cassette to JSON. ",
|
||||
"Does this HTTP interaction contain binary data? ",
|
||||
"If so, use a different serializer (like the yaml serializer) for",
|
||||
"this request"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user