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

[Code Health] Simplify error object usage #347

Closed
5 tasks
bryanchriswhite opened this issue Jan 25, 2024 · 1 comment · Fixed by #422
Closed
5 tasks

[Code Health] Simplify error object usage #347

bryanchriswhite opened this issue Jan 25, 2024 · 1 comment · Fixed by #422
Labels
code health Cleans up some code community A ticket intended to potentially be picked up by a community member on-chain On-chain business logic

Comments

@bryanchriswhite
Copy link
Contributor

bryanchriswhite commented Jan 25, 2024

Objective

Simplify usage of cosmos-sdk error objects. Prefer calling #Wrap()/[#Wrapf()](https://pkg.go.dev/cosmossdk.io/[email protected]#Error.Wrapf) methods over using Wrap()/Wrapf() static functions to improve readability.

Origin Document

#328 (comment)

image

Goals

  • Improve readability by simplifying unnecessarily verbose error construction.

Deliverables

  • A single PR that removes all usage of the static functions referenced in the objective above where the error being passed is a sdkerrors.Error, calling it's respective method instead.
    • The following was verified on VSCode, but the regex pattern likely works on other IDEs as well
A source code-wise find-replace using regex pattern match
// of `sdkerrors\.Wrapf\(([a-zA-Z]+), ` with `$1.Wrapf(`

Non-goals / Non-deliverables

  • Updating error message format/strings
  • Renaming error variables
  • Updating error handling logic

General deliverables

  • Comments: Add/update TODOs and comments alongside the source code so it is easier to follow.
  • Testing: Add new tests (unit and/or E2E) to the test suite.
  • Makefile: Add new targets to the Makefile to make the new functionality easier to use.
  • Documentation: Update architectural or development READMEs; use mermaid diagrams where appropriate.

Creator: @bryanchriswhite
Co-Owners: @h5law

@Olshansk
Copy link
Member

@bryanchriswhite Got a similar comment from @h5law on my PR and confirmed that we can just do a global regex find+replace.

// TODO_TECHDEBT: Do a source code wise find-replace using regex pattern match
// of `sdkerrors\.Wrapf\(([a-zA-Z]+), ` with `$1.Wrapf(`

Screenshot 2024-01-25 at 11 22 37 AM

@Olshansk Olshansk added the community A ticket intended to potentially be picked up by a community member label Feb 2, 2024
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Shannon Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code health Cleans up some code community A ticket intended to potentially be picked up by a community member on-chain On-chain business logic
Projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

2 participants