miden-vm
miden-vm copied to clipboard
Include the constant name for assert error messages
We are using assert.err=<code>
to give context for a given error. <code>
may be a integer or a constant, a failing assert like assert.err=ERR_INVALID_NOTE_TYPE
will then result in an error similar to:
ExecuteTransactionProgramFailed(FailedAssertion { clk: 10244, err_code: 131140, err_msg: None })
There are a few issues with the above:
- We are defining the constants using hex, and not integer, so looking for
131140
in the code base will give no results - The number of prefixed zeros in the hex string is variable, so looking for
0x20044
may not give a hit, for the example above the value was defined as0x00020044
The above makes it unnecessarily convoluted to find the corresponding error. A simple fix for this is to add the string <code>
in the error message. So the error above would be:
ExecuteTransactionProgramFailed(FailedAssertion { clk: 10244, err_code: 131140, err: "ERR_INVALID_NOTE_TYPE" err_msg: None })
If defined with a hex directly, i.e. assert.err=0x00020044
:
ExecuteTransactionProgramFailed(FailedAssertion { clk: 10244, err_code: 131140, err: "0x00020044" err_msg: None })
And if defined with a number, i.e. assert.err=131140
:
ExecuteTransactionProgramFailed(FailedAssertion { clk: 10244, err_code: 131140, err: "131140" err_msg: None })