Skip to content

Commit

Permalink
Simplified error details in path epic
Browse files Browse the repository at this point in the history
  • Loading branch information
nephix committed Feb 14, 2020
1 parent 222162b commit 1a37dcc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 15 deletions.
2 changes: 1 addition & 1 deletion raiden-ts/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const getContracts = (network: Network): ContractsInfo => {
...goerliServicesDeploy.contracts,
} as unknown) as ContractsInfo;
default:
throw new RaidenError(ErrorCodes.RDN_UNRECOGNIZED_NETWORK, [{ network }]);
throw new RaidenError(ErrorCodes.RDN_UNRECOGNIZED_NETWORK, [{ network: network.name }]);
}
};

Expand Down
6 changes: 2 additions & 4 deletions raiden-ts/src/path/epics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ const prepareNextIOU$ = (
const text = await response.text();
if (!response.ok)
throw new RaidenError(ErrorCodes.PFS_LAST_IOU_REQUEST_FAILED, [
{ responseStatus: response.status },
{ responseText: text },
{ responseStatus: response.status, responseText: text },
]);

const { last_iou: lastIou } = decode(LastIOUResults, losslessParse(text));
Expand Down Expand Up @@ -334,8 +333,7 @@ export const pathFindServiceEpic = (
// if error, don't proceed
if (!data.paths) {
throw new RaidenError(ErrorCodes.PFS_ERROR_RESPONSE, [
{ errorCode: data.error.error_code },
{ errors: data.error.errors },
{ errorCode: data.error.error_code, errors: data.error.errors },
]);
}
const filteredPaths: Paths = [],
Expand Down
2 changes: 1 addition & 1 deletion raiden-ts/src/transport/epics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ export const matrixPresenceUpdateEpic = (
const recovered = verifyMessage(userId, displayName) as Address | undefined;
if (!recovered || recovered !== address)
throw new RaidenError(ErrorCodes.TRNS_USERNAME_VERIFICATION_FAILED, [
{ userId, receivedSignature: recovered },
{ userId, receivedSignature: recovered! },
]);
return recovered;
}),
Expand Down
15 changes: 6 additions & 9 deletions raiden-ts/tests/unit/epics/path.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ describe('PFS: pathFindServiceEpic', () => {
pathFind.failure(
expect.objectContaining({
message: ErrorCodes.PFS_ERROR_RESPONSE,
details: [{ errorCode: 1337 }, { errors: 'No route' }],
details: [{ errorCode: 1337, errors: 'No route' }],
}),
{ tokenNetwork, target, value },
),
Expand Down Expand Up @@ -925,10 +925,7 @@ describe('PFS: pathFindServiceEpic', () => {
pathFind.failure(
expect.objectContaining({
message: ErrorCodes.PFS_ERROR_RESPONSE,
details: expect.arrayContaining([
{ errorCode: 2201 },
{ errors: 'No route between nodes found.' },
]),
details: [{ errorCode: 2201, errors: 'No route between nodes found.' }],
}),
{ tokenNetwork, target, value },
),
Expand Down Expand Up @@ -975,7 +972,7 @@ describe('PFS: pathFindServiceEpic', () => {
pathFind.failure(
expect.objectContaining({
message: ErrorCodes.PFS_LAST_IOU_REQUEST_FAILED,
details: expect.arrayContaining([{ responseStatus: 500 }, { responseText: '{}' }]),
details: [{ responseStatus: 500, responseText: '{}' }],
}),
{ tokenNetwork, target, value },
),
Expand Down Expand Up @@ -1101,13 +1098,13 @@ describe('PFS: pathFindServiceEpic', () => {
pathFind.failure(
expect.objectContaining({
message: ErrorCodes.PFS_ERROR_RESPONSE,
details: expect.arrayContaining([
details: [
{
errors:
'The IOU is already claimed. Please start new session with different `expiration_block`.',
errorCode: 2105,
},
{ errorCode: 2105 },
]),
],
}),
{ tokenNetwork, target, value },
),
Expand Down

0 comments on commit 1a37dcc

Please sign in to comment.