smartcontractkit / near-protocol-contracts

MIT License
26 stars 8 forks source link

Contract does not return error message on a failed transaction #28

Open krebernisak opened 4 years ago

krebernisak commented 4 years ago

This is the CLI output:

Scheduling a call: oracle.chainlink_dev.testnet.request({"payment": "10", "spec_id": "NGE1ZWRlYzFlMmMxNDJjMzk4MTMyMmRlMzcwOWRjNTI=", "callback_address": "client.chainlink_dev.testnet", "callback_method": "token_price_callback", "nonce": "5", "data_version": "1", "data": "eyJnZXQiOiJodHRwczovL21pbi1hcGkuY3J5cHRvY29tcGFyZS5jb20vZGF0YS9wcmljZT9mc3ltPUVUVEgmdHN5bXM9VVNEIiwicGF0aCI6IlVTRCIsInRpbWVzIjoxMDB9"})
^[[AReceipt: C2GLsZic8Djf3fcpSUbQTaRn7fcKKNnQVs9TZy6JCu6
    Failure [oracle.chainlink_dev.testnet]: Error: Smart contract panicked: panicked at src/lib.rs:100:13
Error:  GuestPanic [Error]: Smart contract panicked: panicked at src/lib.rs:100:13
    at Object.parseRpcError (/usr/local/lib/node_modules/near-shell/node_modules/near-api-js/lib/utils/rpc_errors.js:38:19)
    at Account.signAndSendTransaction (/usr/local/lib/node_modules/near-shell/node_modules/near-api-js/lib/account.js:144:36)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async scheduleFunctionCall (/usr/local/lib/node_modules/near-shell/commands/call.js:28:34)
    at async Object.handler (/usr/local/lib/node_modules/near-shell/utils/exit-on-error.js:37:9) {
  type: 'GuestPanic',
  index: 0,
  panic_msg: 'panicked at src/lib.rs:100:13'

I would expect a message Invalid, already used nonce: 5, but it's not there.

The check that fails uses assert!, should the contracts use env::panic directly to output the error message to the user?