Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use custom exception classes #572

Open
JakeUrban opened this issue Dec 7, 2021 · 0 comments
Open

Use custom exception classes #572

JakeUrban opened this issue Dec 7, 2021 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@JakeUrban
Copy link
Contributor

JakeUrban commented Dec 7, 2021

Polaris currently expects anchors to raise various built-in exception classes when calling integration class functions. For example, Polaris expects DepositIntegration.process_sep6_request() to raise a ValueError if the client's request is invalid in some way that Polaris itself cannot validate.

There are two reasons why this is not ideal:

  • Built-in exceptions could be unintentionally raised as a result of a bug in the anchor's implementation.
    • Polaris may treat these exceptions as proper behavior if the raised exception is expected for a specific error case.
  • Polaris isn't able to disambiguate error cases that use the same built-in exception class.
    • For example, if an anchor raises a RuntimeError from CustodyIntegration.create_destination_account(), it could be because the source account doesn't exist or it could be because transaction submission failed, and Polaris cannot currently determine which is the case

Instead, Polaris should use custom exceptions that inherit from built-ins, just like the Python SDK does. Anchors will be required to update their implementations to raise the correct exceptions, so we'll have to wait until v3.0 to implement this for existing integrations.

That being said, we could add custom built-in exceptions for new integrations, such the CustodyIntegration class that currently being developed.

@JakeUrban JakeUrban self-assigned this Dec 7, 2021
@JakeUrban JakeUrban added this to the 3.0 milestone Dec 7, 2021
@JakeUrban JakeUrban added the enhancement New feature or request label Dec 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant