Skip to content

Commit

Permalink
chore: serialize when logging errors (hoppscotch#2775)
Browse files Browse the repository at this point in the history
  • Loading branch information
amk-dev committed Oct 11, 2022
1 parent 4d19b92 commit 971238c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
24 changes: 18 additions & 6 deletions packages/hoppscotch-app/src/helpers/teams/TeamCollectionAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand All @@ -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,
Expand All @@ -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)
})
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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)
})
Expand Down
4 changes: 3 additions & 1 deletion packages/hoppscotch-app/src/helpers/teams/TeamListAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 971238c

Please sign in to comment.