Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic in Clarity contracts should provide a meaningful error message #3177

Open
njordhov opened this issue Jun 21, 2022 · 3 comments
Open

Panic in Clarity contracts should provide a meaningful error message #3177

njordhov opened this issue Jun 21, 2022 · 3 comments
Assignees
Labels
event-stream icebox Issues that are not being worked on

Comments

@njordhov
Copy link
Contributor

njordhov commented Jun 21, 2022

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.

See also:

@project-bot project-bot bot added this to New Issues in Stacks Blockchain Board Jun 21, 2022
@jcnelson
Copy link
Member

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?

@njordhov
Copy link
Contributor Author

@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.

@jcnelson
Copy link
Member

jcnelson commented Feb 22, 2023

Temporarily assigning to @obycode. Feel free to re-assign :)

EDIT: damn fat fingers

Stacks Blockchain Board automation moved this from New Issues to Done Feb 22, 2023
@jcnelson jcnelson reopened this Feb 22, 2023
Stacks Blockchain Board automation moved this from Done to In progress Feb 22, 2023
@obycode obycode added the icebox Issues that are not being worked on label Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
event-stream icebox Issues that are not being worked on
Projects
Stacks Blockchain Board
  
In progress
Status: Status: 🆕 New
Development

No branches or pull requests

3 participants