t
tRPC
V
tRPC
•
3y ago
•
2 replies
valtyr
Middleware that returns data instead of throwing error
Is there any way for a middleware to return typed data instead of throwing an error
? I can only see examples of the latter
.
I
'm thinking about something like this
:
procedure.
use
((
opts
)
=>
{
if
(
/*...*/
)
return
{type:
'error'
}
as
const
;
return
opts.
next
(opts);
})
procedure.
use
((
opts
)
=>
{
if
(
/*...*/
)
return
{type:
'error'
}
as
const
;
return
opts.
next
(opts);
})
It would then augment the output type of the procedure with the output type of the middleware
.
tRPC
Join
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015
Members
View on Discord
Resources
ModelContextProtocol
ModelContextProtocol
MCP Server
Recent Announcements
Similar Threads
Was this page helpful?
Yes
No
Similar Threads
Mock form data middleware (
N
Neon / ❓-help
2y ago
Error calling middleware
B
bill92 / ❓-help
2y ago
Zod Error Middleware
Z
zomars / ❓-help
4y ago
subscription tracked returns a 3-tuple to frontend instead of object
H
h3llo / ❓-help
14mo ago