Skip to content

A single exception type is not enough #7

@ghola

Description

@ghola

Easypost API requests can lead to (at least) two major error types:

  • Network related errors - DNS resolving, connection, transfer, etc. ... this would include the network errors Easypost encounters while calling the carrier APIs.
  • Any other error - data validation errors for example

A client encountering a network related error should retry the request but should not retry it for data validation errors. Currently there is no way a client can differentiate between these error types as there is a single Exception class. So given a background process (or daemon) for address validation or label purchasing, that process is required to keep retrying regardless of the error it encounters. The alternative to that is to detect the error type by parsing the exception message, but that would be a very bad practice, nevermind an almost impossible task since we have no way of knowing all the errors that can appear.

I'm sure you can see how this is a waste of resources for all parties involved, and that letting the client know when to retry (and possibly with what delay) is rather essential.

Metadata

Metadata

Assignees

Labels

enhancementIntroduces a new feature or improvementproposalProposal or draft for a major change

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions