Skip to content

multi: Misc error simplification and cleanup. #3491

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

Merged
merged 1 commit into from
Jun 12, 2025

Conversation

davecgh
Copy link
Member

@davecgh davecgh commented Jun 12, 2025

This does some basic error-related housekeeping to simplify all print-related formatting as follows:

  • Use the error directly as opposed to unnecessarily manually invoking the Error method
  • Avoid unneeded formatting directives when the output only consists of the error itself
  • Use const strings when matching on fixed error strings
  • Wrap errors when using fmt.Errorf

@davecgh davecgh added this to the 2.1.0 milestone Jun 12, 2025
This does some basic error-related housekeeping to simplify all
print-related formatting as follows:

- Use the error directly as opposed to unnecessarily manually invoking
  the Error method
- Avoid unneeded formatting directives when the output only consists of
  the error itself
- Use const strings when matching on fixed error strings
- Wrap errors when using fmt.Errorf
@davecgh davecgh force-pushed the multi_misc_error_cleanup branch from 38fd3f6 to 04c4e2d Compare June 12, 2025 21:56
@@ -1163,8 +1163,7 @@ func TestGetSStxNullOutputAmounts(t *testing.T) {
amtTicket)

// len commit to amts != len change amts
lenErrStr := "amounts was not equal in length " +
"to change amounts!"
const lenErrStr = "amounts was not equal in length to change amounts!"
Copy link
Member

@jrick jrick Jun 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow these error messages are gross.

besides that, it would be nice to have some defined error variables to test this against (they don't need to be exported).

Copy link
Member Author

@davecgh davecgh Jun 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I noticed they really need to be cleaned up and converted to errors.Is and all like the rest of the code too, but was limiting the scope of this PR. Plus, a lot of this module will eventually be rewritten/cleaned in favor of the primitives module.

@davecgh davecgh merged commit 04c4e2d into decred:master Jun 12, 2025
2 checks passed
@davecgh davecgh deleted the multi_misc_error_cleanup branch June 12, 2025 23:51
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