Skip to content

Commit

Permalink
refactor: rename reportError to reportException 🪲 (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
aarontorres0 authored May 1, 2024
1 parent 894b879 commit c86cb56
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
} from '@oyster/ui';

import { Route } from '../shared/constants';
import { claimSwagPack, db, reportError } from '../shared/core.server';
import { claimSwagPack, db, reportException } from '../shared/core.server';
import { ClaimSwagPackInput } from '../shared/core.ui';
import { ensureUserAuthenticated, user } from '../shared/session.server';

Expand Down Expand Up @@ -81,7 +81,7 @@ export async function action({ request }: ActionFunctionArgs) {

return redirect(Route.CLAIM_SWAG_PACK_CONFIRMATION);
} catch (e) {
reportError(e);
reportException(e);

return json({
error: `Something went wrong. Please double check that you have a valid address. If you are still having trouble, reach out to [email protected] for further assistance.`,
Expand Down
4 changes: 2 additions & 2 deletions apps/member-profile/app/routes/companies.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
import { z } from 'zod';

import {
reportError,
reportException,
searchCrunchbaseOrganizations,
} from '../shared/core.server';
import { ensureUserAuthenticated } from '../shared/session.server';
Expand All @@ -33,7 +33,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
companies,
});
} catch (e) {
reportError(e);
reportException(e);

return json({
companies: [],
Expand Down
4 changes: 2 additions & 2 deletions apps/member-profile/app/routes/integrations.oauth.github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ENV } from '../shared/constants.server';
import {
authenticateWithGithub,
getGithubProfile,
reportError,
reportException,
updateMember,
} from '../shared/core.server';
import { ensureUserAuthenticated, user } from '../shared/session.server';
Expand Down Expand Up @@ -53,7 +53,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
memberId,
});

reportError(error);
reportException(error);
}

return redirect(Route['/profile/integrations']);
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/infrastructure/bull/use-cases/job.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type JobsOptions } from 'bullmq';

import { reportError } from '@/modules/sentry/use-cases/report-error';
import { reportException } from '@/modules/sentry/use-cases/report-exception';
import { QueueFromName } from '../bull';
import { BullJob, type BullQueue, type GetBullJobData } from '../bull.types';

Expand All @@ -15,7 +15,7 @@ export function job<JobName extends BullJob['name']>(
});

if (!result.success) {
reportError(result.error);
reportException(result.error);

return;
}
Expand All @@ -25,7 +25,7 @@ export function job<JobName extends BullJob['name']>(
const queueName = QueueNameFromJobName[job.name];
const queue = QueueFromName[queueName];

queue.add(job.name, job.data, options).catch((e) => reportError(e));
queue.add(job.name, job.data, options).catch((e) => reportException(e));
}

const QueueNameFromJobName: Record<BullJob['name'], BullQueue> = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { type Job, QueueEvents, Worker, type WorkerOptions } from 'bullmq';
import { Redis } from 'ioredis';
import { type z, type ZodType } from 'zod';

import { reportError } from '@/modules/sentry/use-cases/report-error';
import { reportException } from '@/modules/sentry/use-cases/report-exception';
import { ENV } from '@/shared/env';
import { ErrorWithContext, ZodParseError } from '@/shared/errors';
import { type BullQueue } from '../bull.types';
Expand Down Expand Up @@ -40,7 +40,7 @@ export function registerWorker<Schema extends ZodType>(
});

queueEvents.on('failed', ({ failedReason, jobId }) => {
reportError(
reportException(
new BullJobFailedError(failedReason).withContext({
jobId,
})
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/member-profile.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export { changePrimaryEmail } from './modules/member/use-cases/change-primary-em
export { joinMemberDirectory } from './modules/member/use-cases/join-member-directory';
export { updateAllowEmailShare } from './modules/member/use-cases/update-allow-email-share';
export { updateMember } from './modules/member/use-cases/update-member';
export { reportError } from './modules/sentry/use-cases/report-error';
export { reportException } from './modules/sentry/use-cases/report-exception';
export { countMessagesSent } from './modules/slack/queries/count-messages-sent';
export { claimSwagPack } from './modules/swag-pack/use-cases/claim-swag-pack';
export { getIpAddress } from './shared/utils/ip.utils';
4 changes: 2 additions & 2 deletions packages/core/src/modules/event/airmeet-event.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Event, EventAttendee } from '@oyster/types';
import { sleep } from '@oyster/utils';

import { redis, RedisKey } from '@/infrastructure/redis';
import { reportError } from '@/modules/sentry/use-cases/report-error';
import { reportException } from '@/modules/sentry/use-cases/report-exception';
import { ENV, IS_PRODUCTION } from '@/shared/env';
import { ErrorWithContext } from '@/shared/errors';
import { validate } from '@/shared/utils/zod.utils';
Expand Down Expand Up @@ -258,7 +258,7 @@ export async function registerForAirmeetEvent(input: RegisterForEventInput) {
if (!response.ok) {
const error = new RegisterForAirmeetEventError().withContext(data);

reportError(error);
reportException(error);
throw error;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/modules/member/events/member-created.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { type GetBullJobData } from '@/infrastructure/bull/bull.types';
import { job } from '@/infrastructure/bull/use-cases/job';
import { db } from '@/infrastructure/database';
import { addMailchimpListMember } from '@/modules/mailchimp/use-cases/add-mailchimp-list-member';
import { reportError } from '@/modules/sentry/use-cases/report-error';
import { reportException } from '@/modules/sentry/use-cases/report-exception';

type StudentCreatedInput = GetBullJobData<'student.created'>;

Expand Down Expand Up @@ -45,6 +45,6 @@ export async function onMemberCreated(input: StudentCreatedInput) {
lastName: student.lastName,
});
} catch (e) {
reportError(e);
reportException(e);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { type GetBullJobData } from '@/infrastructure/bull/bull.types';
import { job } from '@/infrastructure/bull/use-cases/job';
import { db } from '@/infrastructure/database';
import { updateMailchimpListMember } from '@/modules/mailchimp/use-cases/update-mailchimp-list-member';
import { reportError } from '@/modules/sentry/use-cases/report-error';
import { reportException } from '@/modules/sentry/use-cases/report-exception';
import {
getSlackUserByEmail,
updateSlackEmail,
Expand Down Expand Up @@ -82,7 +82,7 @@ async function updateEmailMarketingMember(
id: input.previousEmail,
});
} catch (e) {
reportError(e);
reportException(e);
}
}

Expand Down Expand Up @@ -113,6 +113,6 @@ async function updateEmailOnSlack(input: UpdateSlackUserInput) {

await updateSlackEmail(id, input.email);
} catch (e) {
reportError(e);
reportException(e);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
ErrorWithContext,
} from '@/shared/errors';

export function reportError(error: unknown): void {
export function reportException(error: unknown): void {
let context: ErrorContext | undefined = undefined;
let level: ErrorLevel = 'error';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { z } from 'zod';

import { job } from '@/infrastructure/bull/use-cases/job';
import { redis } from '@/infrastructure/redis';
import { reportError } from '@/modules/sentry/use-cases/report-error';
import { reportException } from '@/modules/sentry/use-cases/report-exception';
import { ErrorWithContext, ZodParseError } from '@/shared/errors';
import { RateLimiter } from '@/shared/utils/rate-limiter';

Expand Down Expand Up @@ -43,7 +43,7 @@ export async function deactivateSlackUser(id: string) {
}

if (error) {
reportError(error);
reportException(error);
throw error;
}

Expand Down Expand Up @@ -86,7 +86,7 @@ export async function inviteSlackUser(email: string) {
}

if (error) {
reportError(error);
reportException(error);
throw error;
}

Expand Down

0 comments on commit c86cb56

Please sign in to comment.