Skip to content

Commit

Permalink
fix: error handler fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
felipeneuhauss committed Feb 23, 2023
1 parent 42d3b8f commit 2a8f30d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 150 deletions.
28 changes: 0 additions & 28 deletions .github/workflows/sync_upstream_develop.yml

This file was deleted.

30 changes: 0 additions & 30 deletions .github/workflows/sync_upstream_main.yml

This file was deleted.

29 changes: 15 additions & 14 deletions api-gateway/src/api/service/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,12 @@ tokenAPI.put('/:tokenId/associate', permissionHelper(UserRole.USER), async (req:
const status = await guardians.associateToken(tokenId, userDid);
return res.json(status);
} catch (error) {
console.log('foooooooo', error);
new Logger().error(error, ['API_GATEWAY']);
if (error.toLowerCase().includes('user not found')) {
if (error?.message?.toLowerCase().includes('user not found')) {
return next(createError(404, 'User not found'));
}
if (error.toLowerCase().includes('token not found')) {
if (error?.message?.toLowerCase().includes('token not found')) {
return next(createError(404, 'Token not found'));
}
return next(error);
Expand Down Expand Up @@ -276,10 +277,10 @@ tokenAPI.put('/:tokenId/dissociate', permissionHelper(UserRole.USER), async (req
return res.json(status);
} catch (error) {
new Logger().error(error, ['API_GATEWAY']);
if (error.toLowerCase().includes('user not found')) {
if (error?.message?.toLowerCase().includes('user not found')) {
return next(createError(404, 'User not found'));
}
if (error.toLowerCase().includes('token not found')) {
if (error?.message?.toLowerCase().includes('token not found')) {
return next(createError(404, 'Token not found'));
}
return next(error);
Expand Down Expand Up @@ -318,10 +319,10 @@ tokenAPI.put('/:tokenId/:username/grant-kyc', permissionHelper(UserRole.STANDARD
return res.json(await guardians.grantKycToken(tokenId, username, userDid));
} catch (error) {
new Logger().error(error, ['API_GATEWAY']);
if (error.toLowerCase().includes('user not found')) {
if (error?.message?.toLowerCase().includes('user not found')) {
return next(createError(404, 'User not found'));
}
if (error.toLowerCase().includes('token not found')) {
if (error?.message?.toLowerCase().includes('token not found')) {
return next(createError(404, 'Token not found'));
}
return next(error);
Expand Down Expand Up @@ -363,10 +364,10 @@ tokenAPI.put('/:tokenId/:username/revoke-kyc', permissionHelper(UserRole.STANDAR
return res.json(result);
} catch (error) {
new Logger().error(error, ['API_GATEWAY']);
if (error.toLowerCase().includes('user not found')) {
if (error?.message?.toLowerCase().includes('user not found')) {
return next(createError(404, 'User not found'));
}
if (error.toLowerCase().includes('token not found')) {
if (error?.message?.toLowerCase().includes('token not found')) {
return next(createError(404, 'Token not found'));
}
return next(error);
Expand Down Expand Up @@ -408,10 +409,10 @@ tokenAPI.put('/:tokenId/:username/freeze', permissionHelper(UserRole.STANDARD_RE
return res.json(result);
} catch (error) {
new Logger().error(error, ['API_GATEWAY']);
if (error.toLowerCase().includes('user not found')) {
if (error?.message?.toLowerCase().includes('user not found')) {
return next(createError(404, 'User not found'));
}
if (error.toLowerCase().includes('token not found')) {
if (error?.message?.toLowerCase().includes('token not found')) {
return next(createError(404, 'Token not found'));
}
return next(error);
Expand All @@ -431,10 +432,10 @@ tokenAPI.put('/:tokenId/:username/unfreeze', permissionHelper(UserRole.STANDARD_
return res.json(result);
} catch (error) {
new Logger().error(error, ['API_GATEWAY']);
if (error.toLowerCase().includes('user not found')) {
if (error?.message?.toLowerCase().includes('user not found')) {
return next(createError(404, 'User not found'));
}
if (error.toLowerCase().includes('token not found')) {
if (error?.message?.toLowerCase().includes('token not found')) {
return next(createError(404, 'Token not found'));
}
return next(error);
Expand Down Expand Up @@ -499,10 +500,10 @@ tokenAPI.get('/:tokenId/:username/info', permissionHelper(UserRole.STANDARD_REGI
return res.json(result as ITokenInfo);
} catch (error) {
new Logger().error(error, ['API_GATEWAY']);
if (error.toLowerCase().includes('user not found')) {
if (error?.message?.toLowerCase().includes('user not found')) {
return next(createError(404, 'User not found'));
}
if (error.toLowerCase().includes('token not found')) {
if (error?.message?.toLowerCase().includes('token not found')) {
return next(createError(404, 'Token not found'));
}
return next(error);
Expand Down
76 changes: 0 additions & 76 deletions api-gateway/src/api/service/trustchains.ts

This file was deleted.

6 changes: 4 additions & 2 deletions frontend/src/app/views/header/header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,10 @@ export class HeaderComponent implements OnInit {
this.balanceType = '';
});

this.authSubscription = this.auth.subscribe(() => {
this.getBallance();
this.authSubscription = this.auth.subscribe((token) => {
if (token) {
this.getBallance();
}
})
}

Expand Down

0 comments on commit 2a8f30d

Please sign in to comment.