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

Suggestion: Better error messages #200

Open
showered opened this issue May 21, 2022 · 3 comments
Open

Suggestion: Better error messages #200

showered opened this issue May 21, 2022 · 3 comments

Comments

@showered
Copy link
Contributor

The issue:

Here is an example response:

{
  ...
  res: {
    ...
    data: {
      ...
        errors: [
          'Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 1: invalid account data for instruction'
        ],
    },
  },
}

The SDK/API correctly tells me that there is an error when trying to process a payment. In this case the issue is that the destination address doesn't exist.

The problem is, the error message is far too long, and possibly subject to change. In our code, it is not realistic to write something like:

if (response.res.data.errors[0] === 'Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 1: invalid account data for instruction') {
  console.log('Destination account doesn\'t exist!');
}

The solution:

It would be better if the client received an error from a known list of possible options. For example, the above example should return "DestinationNotFound" or something like that.

The existing Node SDK that uses Agora has the following error mesages:

    AccountExists,
    AccountDoesNotExist,
    Malformed,
    SenderDoesNotExist,
    DestinationDoesNotExist,
    InsufficientBalance,
    InsufficientFee,
    TransactionRejected,
    AlreadyPaid,
    WrongDestination,
    SkuNotFound,
    BadNonce,
    AlreadySubmitted,
    NoTokenAccounts,
@RamirezAlex RamirezAlex self-assigned this May 21, 2022
@RamirezAlex
Copy link
Contributor

Thanks @showered for point it out. I will work on this one next week.

@beeman
Copy link
Contributor

beeman commented May 21, 2022

Great suggestion. This is also related to #121

@beeman
Copy link
Contributor

beeman commented Jun 24, 2022

@showered in #287 we added initial support for better error handling. It should now give back messages like Insufficient funds or Account already exists. Feel free to give it a go and let us know what you think!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants