Errors¶
Every error the SDK raises on purpose is a SanMarError, so one
except clause catches anything SanMar or the network did. Each is raised from the
zeep, requests or paramiko error underneath, which stays available as __cause__.
SanMarError
├── SanMarConnectionError SanMar could not be reached, or answered with an HTTP error
├── SoapFaultError a SOAP fault SanMar did not explain further
├── ResponseError SanMar's response did not match its own WSDL
├── FileFormatError a data file did not have the expected layout
└── ServiceError SanMar reported an error for the request
├── AuthenticationError
├── AuthorizationError
├── NotFoundError
└── RequestError
Mistakes the SDK can catch before sending anything, such as a PO number with a comma or a
date range SanMar would refuse, raise Pydantic’s ValidationError or
ValueError instead, and nothing is sent.
Nothing found¶
Methods that return a list return an empty one when SanMar finds nothing. Methods that
return one thing, such as an invoice or a product, raise NotFoundError.
SanMar’s own services¶
SanMar’s own services report errors as a flag and a message, or as a SOAP fault, never with
a code. The message decides the exception: a failed login is an
AuthenticationError, an unknown style, color or size a
NotFoundError (with a reminder about catalog colors when a color was
given), and anything else invalid a RequestError.
PromoStandards¶
PromoStandards services report errors with a code, which
code carries:
Codes |
Meaning |
Raised as |
|---|---|---|
100, 105, 110 |
Unknown account, or credentials missing or wrong |
|
104 |
The account is not authorized for this service |
|
130, 135, 140, 145, 150, 200 |
Product, part, color or size not found |
|
160 |
No results |
An empty list, or |
301 |
Purchase order or invoice not found (yet) |
|
115, 120, 125, 155, 300, 302, 303 |
Missing or invalid field, unsupported request, bad date or range |
|
999, and any other |
General error |
Information and warning messages are not errors. They go to the sanmar_sdk logger, at
debug and warning level.