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

Refactor errors to JSON and use explicit validation errors #1649

Merged
merged 2 commits into from
Jun 9, 2020

Conversation

andrevmatos
Copy link
Contributor

@andrevmatos andrevmatos commented Jun 9, 2020

Part of #173

Short description
Needed so the CLI refactoring (#1636) can rely on SDK's validations, we need to have explicit error codes/messages thrown upon such validation errors.
The catched errors from API methods can be compared either by message or by code literal, like:

try {
  await raiden.getAvailability('0xinvalid');
} catch (err) {
  err.message === ErrorCodes.DTA_INVALID_ADDRESS; // by message
  err.code === 'DTA_INVALID_ADDRESS'; // literal/narrowed type, may require checking instanceof RaidenError
}

Definition of Done

  • Steps to manually test the change have been documented
  • Acceptance criteria are met
  • Change has been manually tested by the reviewer (dApp)

Steps to manually test the change (dApp)

  1. Try the approach on example, and check if it works
  2. Rest of API is tested by e2e tests

@andrevmatos andrevmatos added sdk 🖥 cli 🔤 Command-line SDK-based Node.js Client issues labels Jun 9, 2020
@andrevmatos andrevmatos requested a review from weilbith June 9, 2020 01:47
@andrevmatos andrevmatos self-assigned this Jun 9, 2020
@codecov
Copy link

codecov bot commented Jun 9, 2020

Codecov Report

Merging #1649 into master will decrease coverage by 0.15%.
The diff coverage is 93.18%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1649      +/-   ##
==========================================
- Coverage   96.03%   95.87%   -0.16%     
==========================================
  Files         146      146              
  Lines        5246     5217      -29     
  Branches      969     1015      +46     
==========================================
- Hits         5038     5002      -36     
- Misses        157      162       +5     
- Partials       51       53       +2     
Flag Coverage Δ
#dapp 91.73% <ø> (ø)
#sdk 97.64% <93.18%> (-0.21%) ⬇️
#sdk_integration ?
Impacted Files Coverage Δ
raiden-ts/src/utils/types.ts 95.16% <ø> (-0.43%) ⬇️
raiden-ts/src/helpers.ts 94.01% <50.00%> (+0.05%) ⬆️
raiden-ts/src/utils/error.ts 88.88% <84.21%> (-9.80%) ⬇️
raiden-ts/src/raiden.ts 95.65% <98.11%> (-0.14%) ⬇️
raiden-ts/src/channels/utils.ts 98.14% <100.00%> (ø)
raiden-ts/src/messages/utils.ts 99.00% <100.00%> (+0.01%) ⬆️
raiden-ts/src/transfers/epics/locked.ts 98.20% <100.00%> (+<0.01%) ⬆️
raiden-ts/src/transfers/utils.ts 91.80% <100.00%> (ø)
raiden-ts/src/transport/epics/init.ts 99.04% <100.00%> (ø)
raiden-ts/src/transport/epics/presence.ts 97.64% <100.00%> (+0.02%) ⬆️
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 75934f9...afec723. Read the comment docs.

@weilbith weilbith mentioned this pull request Jun 9, 2020
2 tasks
Copy link
Contributor

@kelsos kelsos left a comment

Choose a reason for hiding this comment

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

Looks good on my side, but it also adds me some more work 😝
Thanks,

@andrevmatos andrevmatos merged commit 92cd754 into master Jun 9, 2020
@andrevmatos andrevmatos deleted the fix/api_errors branch June 9, 2020 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli 🔤 Command-line SDK-based Node.js Client issues sdk 🖥
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants