2023-10-17 04:59:39 +00:00
|
|
|
import { env } from '$env/dynamic/private';
|
2023-10-06 23:08:13 +00:00
|
|
|
import * as Sentry from '@sentry/node';
|
|
|
|
import type { HandleServerError } from '@sveltejs/kit';
|
|
|
|
|
|
|
|
Sentry.init({
|
2023-10-17 04:59:39 +00:00
|
|
|
dsn: env.SENTRY_DSN,
|
2023-10-06 23:08:13 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
interface ServerError extends Error {
|
|
|
|
code?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const handleError: HandleServerError = ({ error, event }) => {
|
2023-10-07 02:36:17 +00:00
|
|
|
Sentry.captureException(error, { extra: { event } });
|
2023-10-06 23:08:13 +00:00
|
|
|
|
2023-10-07 02:36:17 +00:00
|
|
|
return {
|
|
|
|
message: 'Uh oh! An unexpected error occurred.',
|
|
|
|
code: (error as ServerError)?.code ?? '500',
|
|
|
|
};
|
2023-10-06 23:08:13 +00:00
|
|
|
};
|