Function: rbacErrorFormatter()
ts
function rbacErrorFormatter<S>(opts): S & object;Defined in: packages/trpc/src/errors.ts:90
An errorFormatter that adds the guard's RbacErrorBody to the error shape as data.rbac (null for other errors), so clients can read error.data.rbac.reason:
ts
const t = initTRPC.context<Context>().create({ errorFormatter: rbacErrorFormatter })To combine it with your own formatter, call it first and extend what it returns.
Type Parameters
| Type Parameter |
|---|
S extends object |
Parameters
| Parameter | Type |
|---|---|
opts | { error: unknown; shape: S; } |
opts.error | unknown |
opts.shape | S |
Returns
S & object
