-
I want to report errors to a upstream Error Monitoring service (i.e. posthog) whenever a route or Server Action fails. export const errorCheck = publicProcedure
.input(z.object({ trigger: z.boolean() }))
.handler(async ({ context, input, errors }) => {
const { logger } = context
const { trigger } = input
logger.warn(`Incoming error check...? ${trigger}`)
if (trigger)
throw errors.PANIC({
message: "Error Check",
})
return trigger
})
.actionable({ context: { source: "server_action" } }) The panic error is never reported to my aforementioned const { execute } = useServerAction(errorCheck)
// ...
await execute({ trigger }) I tried slapping on an So I have 2 Questions:
(Read this discussion for the client side: #240) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
You can do it with middleware or interceptors (with |
Beta Was this translation helpful? Give feedback.
So I think
middleware
will match your use case, If you don't know you can use Middleware Dependent context for require .use after an auth middleware for example.