fix: improve error handling
- Do not throw in onError callback for server client. This lets the originating error bubble to Next.js. - Do not log errors inside the service token procedure, server client onError callback will log all procedure errors. - Log errors for fetching service token failure.
This commit is contained in:
@@ -124,7 +124,7 @@ export const safeProtectedProcedure = t.procedure.use(async function (opts) {
|
||||
export const serviceProcedure = t.procedure.use(async (opts) => {
|
||||
const { access_token } = await getServiceToken()
|
||||
if (!access_token) {
|
||||
throw internalServerError(`Failed to obtain service token`)
|
||||
throw internalServerError(`[serviceProcedure] No service token`)
|
||||
}
|
||||
return opts.next({
|
||||
ctx: {
|
||||
@@ -144,7 +144,9 @@ export const serviceServerActionProcedure = serverActionProcedure.use(
|
||||
async (opts) => {
|
||||
const { access_token } = await getServiceToken()
|
||||
if (!access_token) {
|
||||
throw internalServerError("Failed to obtain service token")
|
||||
throw internalServerError(
|
||||
"[serviceServerActionProcedure]: No service token"
|
||||
)
|
||||
}
|
||||
return opts.next({
|
||||
ctx: {
|
||||
|
||||
Reference in New Issue
Block a user