fix: add ctx to trpc error output.

This commit is contained in:
Michael Zetterberg
2024-06-26 07:17:07 +02:00
parent 6f15afd8f9
commit 68df666487

View File

@@ -19,7 +19,9 @@ export const contentstackBaseProcedure = t.procedure.use(async function (opts) {
const parsedInput = langInput.safeParse(input)
if (!parsedInput.success) {
throw badRequestError("Missing Lang in tRPC context")
throw badRequestError(
`Missing Lang in tRPC context: ${JSON.stringify(opts.ctx)}`
)
}
return opts.next({
ctx: {
@@ -27,6 +29,7 @@ export const contentstackBaseProcedure = t.procedure.use(async function (opts) {
},
})
}
return opts.next({
ctx: {
lang: opts.ctx.lang,
@@ -36,7 +39,9 @@ export const contentstackBaseProcedure = t.procedure.use(async function (opts) {
export const contentstackExtendedProcedureUID = contentstackBaseProcedure.use(
async function (opts) {
if (!opts.ctx.uid) {
throw badRequestError("Missing UID in tRPC context")
throw badRequestError(
`Missing UID in tRPC context: ${JSON.stringify(opts.ctx)}`
)
}
return opts.next({