File tree Expand file tree Collapse file tree 3 files changed +17
-2
lines changed Expand file tree Collapse file tree 3 files changed +17
-2
lines changed Original file line number Diff line number Diff line change 11# CHANGELOG
22
3+ ## NEXT RELEASE
4+
5+ - Concatenates ` error.message ` if it incorrectly comes back from the API as a list
6+
37## v7.6.0 (2022-09-21)
48
59- Adds support to pass ` end_shipper_id ` on the buy call of a Shipment
Original file line number Diff line number Diff line change 88class Error (Exception ):
99 def __init__ (
1010 self ,
11- message : Optional [str ] = None ,
11+ message : Optional [
12+ Union [str , list ]
13+ ] = None , # message should be a string but can sometimes incorrectly come back as a list
1214 http_status : Optional [int ] = None ,
1315 http_body : Optional [Union [str , bytes ]] = None ,
1416 original_exception : Optional [Exception ] = None ,
1517 ):
1618 super (Error , self ).__init__ (message )
17- self .message = message
19+ self .message = ", " . join ( message ) if type ( message ) == list else message
1820 self .http_status = http_status
1921 self .http_body = http_body
2022 self .original_exception = original_exception
Original file line number Diff line number Diff line change @@ -21,3 +21,12 @@ def test_error_no_json():
2121 error = easypost .Error (http_body = "bad json" )
2222
2323 assert error .json_body is None
24+
25+
26+ def test_error_list_message ():
27+ """Tests that we concatenate error messages that are a list (they should be a string from the
28+ API but aren't always so we protect against that here).
29+ """
30+ error = easypost .Error (message = ["Error1" , "Error2" ])
31+
32+ assert error .message == "Error1, Error2"
You can’t perform that action at this time.
0 commit comments