nervosnetwork / nervosnetwork/fiber
[rpc] rpc returns the same error code when an error occurs
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 59
- Forks
- 31
- Avg merge
- 3d 5h
- Merged PRs (30d)
- 18
Description
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."
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No file, test, or RPC entry point is named; begin by locating the RPC error-handling and method-dispatch code. Inventory the existing error cases and define a consistent mapping; done means related RPC failures return stable, distinct codes instead of the shared -32000, including expired-invoice handling.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- api, blockchain
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100