a cache for slack profile pictures and emojis

feat: log extra details with sentry

Changed files
+18 -6
src
+18 -6
src/index.ts
···
},
}),
)
-
.onError(({ code, error }) => {
+
.onError(({ code, error, request }) => {
if (error instanceof Error)
console.error(
`\x1b[31m x\x1b[0m unhandled error: \x1b[31m${error.message}\x1b[0m`,
);
-
Sentry.captureException(error);
+
Sentry.withScope((scope) => {
+
scope.setExtra("url", request.url);
+
scope.setExtra("code", code);
+
Sentry.captureException(error);
+
});
if (code === "VALIDATION") {
return error.message;
}
···
)
.get(
"/users/:user",
-
async ({ params, error }) => {
+
async ({ params, error, request }) => {
const user = await cache.getUser(params.user);
// if not found then check slack first
···
if (e instanceof Error && e.message === "user_not_found")
return error(404, { message: "User not found" });
-
Sentry.captureException(e);
+
Sentry.withScope((scope) => {
+
scope.setExtra("url", request.url);
+
scope.setExtra("user", params.user);
+
Sentry.captureException(e);
+
});
if (e instanceof Error)
console.warn(
···
)
.get(
"/users/:user/r",
-
async ({ params, error, redirect }) => {
+
async ({ params, error, redirect, request }) => {
const user = await cache.getUser(params.user);
// if not found then check slack first
···
if (e instanceof Error && e.message === "user_not_found")
return error(404, { message: "User not found" });
-
Sentry.captureException(e);
+
Sentry.withScope((scope) => {
+
scope.setExtra("url", request.url);
+
scope.setExtra("user", params.user);
+
Sentry.captureException(e);
+
});
if (e instanceof Error)
console.warn(