You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Panic in Clarity contracts results in a useless and uninformative (err none) reported to the caller when the contract aborts, whether triggered by unwrap-panic or a failure such as an uint subtraction underflow.
Instead, a panic should provide a useful error message so the caller can understand why the contract call was aborted.
The lack of helpful panic messages leads to confused developers, ad-hoc workarounds, and avoidance of unwrap-panic, an anti-pattern. The clarity-lang book even explicitly advises against using unwrap-panic due to the lack of a useful response:
You should ideally not use the -panic variants unless you absolutely have to, because they confer no meaningful information when they fail. A transaction will revert with a vague "runtime error" and users as well as developers are left to figure out exactly what went wrong.
Hey @njordhov, are you asking that the transaction receipt include something more informative than (err none)? Because if so, this isn't a breaking change, and could be done in the next release. Please elaborate?
@jcnelson Yes, it's about making the transaction receipt more informative on Clarity panics. Minimally, it should provide an error message with the specific reason for the failure, or the triggering error for unwrap-panic. Better, a record (aka tuple) with more details including the name of the function in which the panic occurred and the location in the contract code of the failing call.
Panic in Clarity contracts results in a useless and uninformative
(err none)
reported to the caller when the contract aborts, whether triggered byunwrap-panic
or a failure such as an uint subtraction underflow.Instead, a panic should provide a useful error message so the caller can understand why the contract call was aborted.
The lack of helpful panic messages leads to confused developers, ad-hoc workarounds, and avoidance of
unwrap-panic
, an anti-pattern. The clarity-lang book even explicitly advises against usingunwrap-panic
due to the lack of a useful response:See also:
panic!
function that will panic code execution with custom error message. #2877-panic
functions clarity-lang/reference#25The text was updated successfully, but these errors were encountered: