H
Hono3mo ago
igmtink

How to handle multiple errors in (react query) using (hono rpc)?

How can I handle multiple errors like in my case? I want to display the error on my signup form layout.
5 Replies
Nico
Nico3mo ago
Can you show the full code? The popup is blocking some, also how you set the types for RPC
igmtink
igmtink3mo ago
I want to get the error message from hono, but there's a type error, even the type of ResponseType is { error: string } | { data: string } I want to display on my sign up layout that multiple error like if Username is already exist or Email is already exist
fOfer
fOfer3mo ago
Curious about this I myself had to do this in my useQuery instances on the client side
async (res) => {
switch (res.status) {
case 500:
throw new errors.ParseError(await res.text())
case 200:
return res.json()
case 404:
default:
throw new errors.NotFoundError(await res.text())
}
}
async (res) => {
switch (res.status) {
case 500:
throw new errors.ParseError(await res.text())
case 200:
return res.json()
case 404:
default:
throw new errors.NotFoundError(await res.text())
}
}
Would love to set this at the hc client level Or create a typesafe function that receives the $get or $post return and apply that validation without loosing typesafety
igmtink
igmtink3mo ago
where did you add this code?
Nico
Nico2mo ago
It should go between your response and data variables. You want it before you convert to JSON
Want results from more Discord servers?
Add your server
More Posts
Type 'Hono<App {...}>' does not satisfy the constraint 'Hono<any, any, any> Property '#private' in tHi, I'm trying to use hono RPC client on my frontend project. But the type not working properly. I'mIs it safe to store user data with set/get?I read (https://github.com/honojs/hono/issues/585#issuecomment-1826189093) that context state can beContextVariableMap not recognized during build from other package in monorepoI created `src/hodo.d.ts` file in my Hono project: ```ts import { User } from './schema'; declare mIs there a way to subscribe/publish with Hono webSocket middleware (for Bun)?I am definitely far from familiarity with websockets but I am excited to try it out with Hono. I am Combine JWT middleware with other middlewareI have a file made `/middleware/jwt.ts`: ```typescript import { Context, Next } from 'hono'; import Proper error logging and tracing?Do you guys have an example repo that properly sets up error logs and trace? It seems too difficultWhat data should be sent from the client to use clerk middleware?I'm working on a react-native app using expo. The back-end is built using nodejs & hono. I'm using cWebsocket with BunI've tried everything but I can't get WebSockets to work with Bun, also the git issues were not helpCustom jwt middlewareI want to check whether the user exists in the database based on the ID that I took from the sub paySentry middleware incomplete reportI want to use Hono + Sentry, the target environment is Cloudflare, but for now I'm running it locall