casper-ecosystem / cep18

Implementation of ERC20 token for the CasperLabs platform.
https://casper.network/docs/dapp-dev-guide
Apache License 2.0
26 stars 47 forks source link

native expansive error topic #150

Closed deuszex closed 2 weeks ago

deuszex commented 3 weeks ago

MessageTopics commit their data onto global state even if the execution fails, which makes them the perfect candidate to use for error logging in case more expansive details are required about the source of an error than what the u16 error codes can confer.

Do not use in unwrap_or_revert_with because they will trigger even if there was no error to unwrap, instead consider the following application

maybe_error.map_err(|err| {
    runtime::emit_message(ERRORS, &format!("custom error message, source error: {err:?}").into()).unwrap_or_revert(); 
    new_error
}).unwrap_or_revert()

this will prevent false positive error messages.