Skip to content

Commit

Permalink
[14.0][ADD] delivery_easypost_oca
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniodavid committed Sep 27, 2024
1 parent 4750cc2 commit 600d225
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions delivery_easypost_oca/models/easypost_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ def buy_shipment(self, shipment, carrier_services=None):
bought_shipment = shipment.buy(
rate=selected_rate, end_shipper_id=end_shipper
)
except Exception as e:
raise UserError(self._get_message_errors(e)) from e
except easypost.Error as error:
raise UserError(self._get_message_errors(error)) from error

Check warning on line 143 in delivery_easypost_oca/models/easypost_request.py

View check run for this annotation

Codecov / codecov/patch

delivery_easypost_oca/models/easypost_request.py#L142-L143

Added lines #L142 - L143 were not covered by tests

return EasyPostShipment(
shipment_id=bought_shipment.id,
Expand Down Expand Up @@ -222,12 +222,9 @@ def retrieve_all_carrier_accounts(self):
raise UserError(self._get_message_errors(e)) from e
return carrier_accounts

Check warning on line 223 in delivery_easypost_oca/models/easypost_request.py

View check run for this annotation

Codecov / codecov/patch

delivery_easypost_oca/models/easypost_request.py#L219-L223

Added lines #L219 - L223 were not covered by tests

def _get_message_errors(self, e: Exception) -> str:
def _get_message_errors(self, e: easypost.Error) -> str:
if not hasattr(e, "errors"):
error_message = e.get("message")
if e.get("http_body", False):
error_message = f"Error: {error_message}\nError Body: {e.http_body}"
return error_message
return getattr(e, "message", str(e))

Check warning on line 227 in delivery_easypost_oca/models/easypost_request.py

View check run for this annotation

Codecov / codecov/patch

delivery_easypost_oca/models/easypost_request.py#L227

Added line #L227 was not covered by tests
return "\n".join(
[
f"Error: {err['message']}\nError Body: {err['http_body']}"
Expand Down

0 comments on commit 600d225

Please sign in to comment.