Skip to content

Commit

Permalink
chore: add more contexts to error
Browse files Browse the repository at this point in the history
  • Loading branch information
wa0x6e committed Aug 18, 2023
1 parent c0b1ec6 commit c765cd8
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/graphql/operations/aliases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default async function (parent, args) {
return await db.queryAsync(query, params);
} catch (e: any) {
log.error(`[graphql] aliases, ${JSON.stringify(e)}`);
capture(e);
capture(e, { contexts: { input: { args } } });
return Promise.reject('request failed');
}
}
2 changes: 1 addition & 1 deletion src/graphql/operations/follows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default async function (parent, args) {
return follows.map(follow => formatFollow(follow));
} catch (e: any) {
log.error(`[graphql] follows, ${JSON.stringify(e)}`);
capture(e);
capture(e, { contexts: { input: { args } } });
return Promise.reject('request failed');
}
}
2 changes: 1 addition & 1 deletion src/graphql/operations/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default async function (parent, args) {
return await db.queryAsync(query, params);
} catch (e: any) {
log.error(`[graphql] messages, ${JSON.stringify(e)}`);
capture(e);
capture(e, { contexts: { input: { args } } });
return Promise.reject('request failed');
}
}
2 changes: 1 addition & 1 deletion src/graphql/operations/proposals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export default async function (parent, args) {
return proposals.map(proposal => formatProposal(proposal));
} catch (e: any) {
log.error(`[graphql] proposals, ${JSON.stringify(e)}`);
capture(e);
capture(e, { contexts: { input: { args } } });
return Promise.reject('request failed');
}
}
4 changes: 2 additions & 2 deletions src/graphql/operations/ranking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import db from '../../helpers/mysql';
import { rankedSpaces } from '../../helpers/spaces';
import { capture } from '@snapshot-labs/snapshot-sentry';

export default async function (_parent, args, _context, info) {
export default async function (_parent, args, context, info) {
checkLimits(args, 'ranking');
try {
const { first = 20, skip = 0, where = {} } = args;
Expand Down Expand Up @@ -54,7 +54,7 @@ export default async function (_parent, args, _context, info) {
} catch (e: any) {
log.error(`[graphql] spaces, ${JSON.stringify(e)}`);
if (e instanceof PublicError) return e;
capture(e);
capture(e, { contexts: { input: { args, context, info } } });
return new Error('Unexpected error');
}
}
4 changes: 2 additions & 2 deletions src/graphql/operations/spaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { checkLimits, fetchSpaces, handleRelatedSpaces, PublicError } from '../h
import log from '../../helpers/log';
import { capture } from '@snapshot-labs/snapshot-sentry';

export default async function (_parent, args, _context, info) {
export default async function (_parent, args, context, info) {
checkLimits(args, 'spaces');
try {
let spaces = await fetchSpaces(args);
Expand All @@ -12,7 +12,7 @@ export default async function (_parent, args, _context, info) {
} catch (e: any) {
log.error(`[graphql] spaces, ${JSON.stringify(e)}`);
if (e instanceof PublicError) return e;
capture(e);
capture(e, { contexts: { input: { args, context, info } } });
return new Error('Unexpected error');
}
}
2 changes: 1 addition & 1 deletion src/graphql/operations/statements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default async function (parent, args) {
return statements;
} catch (e: any) {
log.error(`[graphql] statements, ${JSON.stringify(e)}`);
capture(e);
capture(e, { contexts: { input: { args } } });
return Promise.reject('request failed');
}
}
2 changes: 1 addition & 1 deletion src/graphql/operations/subscriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default async function (parent, args) {
return subscriptions.map(subscription => formatSubscription(subscription));
} catch (e: any) {
log.error(`[graphql] subscriptions, ${JSON.stringify(e)}`);
capture(e);
capture(e, { contexts: { input: { args } } });
return Promise.reject('request failed');
}
}
2 changes: 1 addition & 1 deletion src/graphql/operations/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default async function (parent, args) {
return users.map(user => formatUser(user));
} catch (e: any) {
log.error(`[graphql] users, ${JSON.stringify(e)}`);
capture(e);
capture(e, { contexts: { input: { args } } });
return Promise.reject('request failed');
}
}
6 changes: 3 additions & 3 deletions src/graphql/operations/votes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async function query(parent, args, context?, info?) {
// TODO: we need settings in the vote as its being passed to formatSpace inside formatVote, Maybe we dont need to do this?
votes = votes.map(vote => formatVote(vote));
} catch (e: any) {
capture(e);
capture(e, { contexts: { input: { args, context, info } } });
log.error(`[graphql] votes, ${JSON.stringify(e)}`);
return Promise.reject('request failed');
}
Expand All @@ -69,7 +69,7 @@ async function query(parent, args, context?, info?) {
return vote;
});
} catch (e: any) {
capture(e);
capture(e, { contexts: { input: { args, context, info } } });
log.error(`[graphql] votes, ${JSON.stringify(e)}`);
return Promise.reject('request failed');
}
Expand All @@ -92,7 +92,7 @@ async function query(parent, args, context?, info?) {
return vote;
});
} catch (e: any) {
capture(e);
capture(e, { contexts: { input: { args, context, info } } });
log.error(`[graphql] votes, ${JSON.stringify(e)}`);
return Promise.reject('request failed');
}
Expand Down

0 comments on commit c765cd8

Please sign in to comment.