Skip to content

improve error message in Proof::new to include actual lengths#362

Merged
0g-peterzhb merged 1 commit into0gfoundation:mainfrom
ricecodekhmer:patch-1
Apr 30, 2025
Merged

improve error message in Proof::new to include actual lengths#362
0g-peterzhb merged 1 commit into0gfoundation:mainfrom
ricecodekhmer:patch-1

Conversation

@ricecodekhmer
Copy link
Copy Markdown
Contributor

@ricecodekhmer ricecodekhmer commented Mar 30, 2025

Description:

I encountered an error in the last debugging session while initializing a new Proof using the Proof::new method. The error message simply was:

bail!("hash and path length mismatch");

This message did not include enough context to easily determine the problem. The error didn't state what lengths were being passed.

To improve this, I rewrote the error message to be more helpful. Now, if there is a mismatch, the error message will also indicate the actual lengths of the hash and the path. The new message is:

bail!("Proof::new: expected hash length = path.len() + 2, but got {} and {}", hash.len(), path.len());

This change is Reviewable

@0g-peterzhb 0g-peterzhb merged commit fec6aa5 into 0gfoundation:main Apr 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants