From 971238cedb283d7c33da0d34c4cefd4794326d27 Mon Sep 17 00:00:00 2001 From: Akash K <57758277+amk-dev@users.noreply.github.com> Date: Wed, 12 Oct 2022 02:19:27 +0530 Subject: [PATCH] chore: serialize when logging errors (#2775) --- .../helpers/teams/TeamCollectionAdapter.ts | 24 ++++++++++++++----- .../src/helpers/teams/TeamListAdapter.ts | 4 +++- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/packages/hoppscotch-app/src/helpers/teams/TeamCollectionAdapter.ts b/packages/hoppscotch-app/src/helpers/teams/TeamCollectionAdapter.ts index ae85144d4..49a891bde 100644 --- a/packages/hoppscotch-app/src/helpers/teams/TeamCollectionAdapter.ts +++ b/packages/hoppscotch-app/src/helpers/teams/TeamCollectionAdapter.ts @@ -470,7 +470,9 @@ export default class NewTeamCollectionAdapter { this.teamCollectionAdded$ = teamCollAdded$.subscribe((result) => { if (E.isLeft(result)) - throw new Error(`Team Collection Added Error: ${result.left}`) + throw new Error( + `Team Collection Added Error: ${JSON.stringify(result.left)}` + ) this.addCollection( { @@ -493,7 +495,9 @@ export default class NewTeamCollectionAdapter { this.teamCollectionUpdatedSub = teamCollUpdatedSub this.teamCollectionUpdated$ = teamCollUpdated$.subscribe((result) => { if (E.isLeft(result)) - throw new Error(`Team Collection Updated Error: ${result.left}`) + throw new Error( + `Team Collection Updated Error: ${JSON.stringify(result.left)}` + ) this.updateCollection({ id: result.right.teamCollectionUpdated.id, @@ -511,7 +515,9 @@ export default class NewTeamCollectionAdapter { this.teamCollectionRemovedSub = teamCollRemovedSub this.teamCollectionRemoved$ = teamCollRemoved$.subscribe((result) => { if (E.isLeft(result)) - throw new Error(`Team Collection Removed Error: ${result.left}`) + throw new Error( + `Team Collection Removed Error: ${JSON.stringify(result.left)}` + ) this.removeCollection(result.right.teamCollectionRemoved) }) @@ -526,7 +532,9 @@ export default class NewTeamCollectionAdapter { this.teamRequestAddedSub = teamReqAddedSub this.teamRequestAdded$ = teamReqAdded$.subscribe((result) => { if (E.isLeft(result)) - throw new Error(`Team Request Added Error: ${result.left}`) + throw new Error( + `Team Request Added Error: ${JSON.stringify(result.left)}` + ) this.addRequest({ id: result.right.teamRequestAdded.id, @@ -548,7 +556,9 @@ export default class NewTeamCollectionAdapter { this.teamRequestUpdatedSub = teamReqUpdatedSub this.teamRequestUpdated$ = teamReqUpdated$.subscribe((result) => { if (E.isLeft(result)) - throw new Error(`Team Request Updated Error: ${result.left}`) + throw new Error( + `Team Request Updated Error: ${JSON.stringify(result.left)}` + ) this.updateRequest({ id: result.right.teamRequestUpdated.id, @@ -568,7 +578,9 @@ export default class NewTeamCollectionAdapter { this.teamRequestUpdatedSub = teamReqDeleted this.teamRequestDeleted$ = teamReqDeleted$.subscribe((result) => { if (E.isLeft(result)) - throw new Error(`Team Request Deleted Error ${result.left}`) + throw new Error( + `Team Request Deleted Error ${JSON.stringify(result.left)}` + ) this.removeRequest(result.right.teamRequestDeleted) }) diff --git a/packages/hoppscotch-app/src/helpers/teams/TeamListAdapter.ts b/packages/hoppscotch-app/src/helpers/teams/TeamListAdapter.ts index 16db0acb1..de9c52803 100644 --- a/packages/hoppscotch-app/src/helpers/teams/TeamListAdapter.ts +++ b/packages/hoppscotch-app/src/helpers/teams/TeamListAdapter.ts @@ -65,7 +65,9 @@ export default class TeamListAdapter { if (E.isLeft(result)) { this.error$.next(result.left) - throw new Error(`Failed fetching teams list: ${result.left}`) + throw new Error( + `Failed fetching teams list: ${JSON.stringify(result.left)}` + ) } results.push(...result.right.myTeams)