EOSIO / eos

An open source smart contract platform
https://developers.eos.io/manuals/eos
MIT License
11.27k stars 3.6k forks source link

how to catch defer onerror #6562

Closed boy-good closed 5 years ago

boy-good commented 5 years ago

image defer action maybe onerror how to catch in contract?

spartucus commented 5 years ago

same here, maybe a missing authority of ${account} error?

boy-good commented 5 years ago

@spartucus i found the error maked by contract eosio_assert. the eosx.io can see the error. I want to know how to catch it in contract , like in "apply" function?

hama commented 5 years ago

you should use onerror. https://github.com/EOSIO/eos/blob/ea08cfd3d1a82b634a9e84f971d99708af516c0d/unittests/contracts/deferred_test/deferred_test.cpp#L47

taokayan commented 5 years ago

You need to implement the "onerror" action

boy-good commented 5 years ago

@taokayan @hama only support to print error? Can operate table in "apply_onerror" function like "deferred_test.cpp"?

vtsurka commented 5 years ago

Also interesting how get which assert in deferred transaction trigger onerror situation.

jgiszczak commented 5 years ago

@boy-good There are no restrictions on what can be done in apply_onerror(). See https://github.com/EOSIO/eos/blob/ea08cfd3d1a82b634a9e84f971d99708af516c0d/contracts/proxy/proxy.cpp#L71 for another example. Note that injudicious code could result in permanent loops, so care must be taken.

@vtsurka The above reference shows an example of retrieving the sent transaction in apply_onerror().