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

[rpc] rpc returns the same error code when an error occurs #320

Open
ahonn opened this issue Nov 19, 2024 · 1 comment
Open

[rpc] rpc returns the same error code when an error occurs #320

ahonn opened this issue Nov 19, 2024 · 1 comment

Comments

@ahonn
Copy link

ahonn commented Nov 19, 2024

When an error occurs while calling different RPC methods, the returned error code is always the same (-32000).

As a result, one must rely on the error message, which is not the best practice. To simplify the handling of related errors, it is recommended that RPC error codes be standardized.

For example, when sending payment to an expired invoice, the following error will be returned:

{
  "jsonrpc": "2.0",
  "error": {
    "code": -32000,
    "message": "InvalidParameter: Failed to validate payment request: \"invoice is expired\"",
    "data": {
      "target_pubkey": null,
      "amount": null,
      "payment_hash": null,
      "final_cltv_delta": null,
      "invoice": "fibt10000000001pfw653wmq4nczxzat8almjaujsncds6z3y5989ey5qaj4fm3h6k543smrppgg8rh895jp0g7ndzja6adhc4perqttv4nuqm9rqqal78pcceghel2ce057fm3prdzuklgezp6m4aej4dxy7vhfpf5dup3uz74t52f4nscaw8dlq4vt75e3vd37y3957x5583darjurl9sw8puz5spm4mmcglamtdtpcc997yzm65t2lqsajgkdsfcurgq7zjwdqcdj5q7ydgwn52m7y9gm7zn593fh976r8dw593hasyrwkz9qwz8nnqwk7fgpxkrhmdxgphvjhr5qmqsnaul5mkvxcggtx5s72c8p4h0p996ul27u49smfdqrpqeugvnqecrhczrcj8437hwfunfwjj6rvds6ykszrhv6ez8wykztsy8s6jvdu555z7mu6q7cdvzwnftlnh4f6wljpncjrg58mek3jpq9lytsusd4gv3s3yyqzymyvza20yssevrsdw6rgxx299xvfppgw7mptmg2vf8qlf7hq54gqqmczmma",
      "timeout": null,
      "max_fee_amount": null,
      "max_parts": null,
      "keysend": null,
      "udt_type_script": null,
      "allow_self_payment": true
    }
  },
  "id": 42
}

I can only determine whether the error is due to the expired invoice by checking if the error message contains "invoice is expired."

@chenyukang
Copy link
Collaborator

yeah, we need to improve this.

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

2 participants