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

feat(SPV-846): refactor numeric error codes into strings #627

Merged

Conversation

pawellewandowski98
Copy link
Contributor

Pull Request Checklist

  • πŸ“– I created my PR using provided : CODE_STANDARDS
  • πŸ“– I have read the short Code of Conduct: CODE_OF_CONDUCT
  • 🏠 I tested my changes locally.
  • βœ… I have provided tests for my changes.
  • πŸ“ I have used conventional commits.
  • πŸ“— I have updated any related documentation.
  • πŸ’Ύ PR was issued based on the Github or Jira issue.

Description

  • Refactored way how the errors are return. Now every error which is return from our endpoint is located in spverror package. It is required to define it in two places:
  1. definitions.go - define error which will be used in code
  2. errors.go - it has map which has error as a key and value contain message, status code and code error which will be returned

Example:
request does not have auth header

  • Set error response by method from spverrors package
    image

  • Error defined in ./spverrors/errors.go
    image

  • Response with status 401:
    image

If error is not defined in map we return default error:
image

@pawellewandowski98 pawellewandowski98 self-assigned this Jun 20, 2024
@pawellewandowski98 pawellewandowski98 requested a review from a team as a code owner June 20, 2024 10:53
Copy link

github-actions bot commented Jun 20, 2024

Manual Tests

πŸ’š Manual testing by @chris-4chain resulted in success.

@pawellewandowski98 pawellewandowski98 force-pushed the feat-846-refactor-numeric-error-codes-into-strings branch from 9fd9175 to bfd73e8 Compare June 25, 2024 07:15
@codecov-commenter
Copy link

codecov-commenter commented Jun 25, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 17.66382% with 289 lines in your changes missing coverage. Please review.

Project coverage is 48.89%. Comparing base (dc45064) to head (785af1c).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #627      +/-   ##
==========================================
+ Coverage   48.83%   48.89%   +0.05%     
==========================================
  Files         257      259       +2     
  Lines       11524    11531       +7     
==========================================
+ Hits         5628     5638      +10     
+ Misses       5312     5309       -3     
  Partials      584      584              
Flag Coverage Ξ”
unittests 48.89% <17.66%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Ξ”
engine/client_internal.go 94.31% <ΓΈ> (ΓΈ)
engine/pike/pike.go 70.00% <ΓΈ> (ΓΈ)
models/filter/utils.go 87.09% <100.00%> (ΓΈ)
actions/admin/stats.go 0.00% <0.00%> (ΓΈ)
actions/contacts/accept.go 0.00% <0.00%> (ΓΈ)
actions/contacts/confirm.go 0.00% <0.00%> (ΓΈ)
actions/contacts/models.go 0.00% <0.00%> (ΓΈ)
actions/contacts/reject.go 0.00% <0.00%> (ΓΈ)
actions/contacts/unconfirm.go 0.00% <0.00%> (ΓΈ)
actions/xpubs/get.go 0.00% <0.00%> (ΓΈ)
... and 66 more

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Ξ” = absolute <relative> (impact), ΓΈ = not affected, ? = missing data
Powered by Codecov. Last update dc45064...785af1c. Read the comment docs.

@pawellewandowski98 pawellewandowski98 force-pushed the feat-846-refactor-numeric-error-codes-into-strings branch from c504b0f to f9172bb Compare June 26, 2024 08:27
models/errors.go Outdated Show resolved Hide resolved
Copy link
Contributor

@ac4ch ac4ch left a comment

Choose a reason for hiding this comment

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

except that one file all seems to be good i would say

engine/go.mod Outdated Show resolved Hide resolved
engine/spverrors/definitions.go Outdated Show resolved Hide resolved
@bitcoin-sv bitcoin-sv deleted a comment from ac4ch Jun 26, 2024
@pawellewandowski98 pawellewandowski98 force-pushed the feat-846-refactor-numeric-error-codes-into-strings branch from 62c6f90 to 235969b Compare July 2, 2024 10:53
@chris-4chain chris-4chain added the tested PR was tested by a team member label Jul 4, 2024
@pawellewandowski98 pawellewandowski98 merged commit 40c62e9 into main Jul 4, 2024
13 checks passed
@pawellewandowski98 pawellewandowski98 deleted the feat-846-refactor-numeric-error-codes-into-strings branch July 4, 2024 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tested PR was tested by a team member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants