feat: enhance error messages in middleware to include request URL for better debugging
This commit is contained in:
parent
3ecbc54515
commit
1c2202f604
1 changed files with 7 additions and 7 deletions
|
|
@ -149,7 +149,7 @@ const enforceUserIsAuthed = t.middleware(({ ctx, next, path }) => {
|
|||
if (!ctx.session) {
|
||||
throw new TRPCError({
|
||||
code: "UNAUTHORIZED",
|
||||
message: `User is not logged, error in path: ${path}`,
|
||||
message: `User is not logged, error in path: ${path} [${ctx.req?.url}]`,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -175,7 +175,7 @@ const enforceUserIsAuthedOrOverride = t.middleware(({ ctx, next, path }) => {
|
|||
if (!ctx.session) {
|
||||
throw new TRPCError({
|
||||
code: "UNAUTHORIZED",
|
||||
message: `User is not logged, error in path: ${path}`,
|
||||
message: `User is not logged, error in path: ${path} [${ctx.req?.url}]`,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -205,7 +205,7 @@ const enforceUserIsAdmin = t.middleware(({ ctx, next, path }) => {
|
|||
if (!ctx.session || !ctx.session.isAdmin) {
|
||||
throw new TRPCError({
|
||||
code: "UNAUTHORIZED",
|
||||
message: `User is not Admin, error in path: ${path}`,
|
||||
message: `User is not Admin, error in path: ${path} [${ctx.req?.url}]`,
|
||||
});
|
||||
}
|
||||
return next({
|
||||
|
|
@ -243,14 +243,14 @@ const enforceProtectedApi = t.middleware(async ({ ctx, next, path }) => {
|
|||
if (!ctx.req || !ctx.res) {
|
||||
throw new TRPCError({
|
||||
code: "UNAUTHORIZED",
|
||||
message: `No request or response object, error in path: ${path}`,
|
||||
message: `No request or response object, error in path: ${path} [${ctx.req?.url}]`,
|
||||
});
|
||||
}
|
||||
const basicAuth = ctx.req.headers.authorization;
|
||||
if (!basicAuth) {
|
||||
throw new TRPCError({
|
||||
code: "UNAUTHORIZED",
|
||||
message: `No Auth header found: ${path}`,
|
||||
message: `No Auth header found: ${path} [${ctx.req?.url}]`,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -259,7 +259,7 @@ const enforceProtectedApi = t.middleware(async ({ ctx, next, path }) => {
|
|||
if (!authValue) {
|
||||
throw new TRPCError({
|
||||
code: "UNAUTHORIZED",
|
||||
message: `Auth value invalid: ${path}`,
|
||||
message: `Auth value invalid: ${path} [${ctx.req?.url}]`,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -268,7 +268,7 @@ const enforceProtectedApi = t.middleware(async ({ ctx, next, path }) => {
|
|||
if (user !== env.EXP_API_USER || pwd !== env.EXP_API_PASS) {
|
||||
throw new TRPCError({
|
||||
code: "UNAUTHORIZED",
|
||||
message: `User or Secret not valid: ${path}`,
|
||||
message: `User or Secret not valid: ${path} [${ctx.req?.url}]`,
|
||||
});
|
||||
}
|
||||
return next({
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue