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 1
1
# CHANGELOG
2
2
3
+ ## NEXT RELEASE
4
+
5
+ - Concatenates ` error.message ` if it incorrectly comes back from the API as a list
6
+
3
7
## v7.6.0 (2022-09-21)
4
8
5
9
- Adds support to pass ` end_shipper_id ` on the buy call of a Shipment
Original file line number Diff line number Diff line change 8
8
class Error (Exception ):
9
9
def __init__ (
10
10
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
12
14
http_status : Optional [int ] = None ,
13
15
http_body : Optional [Union [str , bytes ]] = None ,
14
16
original_exception : Optional [Exception ] = None ,
15
17
):
16
18
super (Error , self ).__init__ (message )
17
- self .message = message
19
+ self .message = ", " . join ( message ) if type ( message ) == list else message
18
20
self .http_status = http_status
19
21
self .http_body = http_body
20
22
self .original_exception = original_exception
Original file line number Diff line number Diff line change @@ -21,3 +21,12 @@ def test_error_no_json():
21
21
error = easypost .Error (http_body = "bad json" )
22
22
23
23
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