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