-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing/more errors #82
Comments
Hopefully this helps. It should return a more detailed error. const parseDatabaseError = (error: DatabaseError) => {
try {
const targetArray = error.body.message.split(': ');
return {
type: targetArray[2].split(': ')[0],
code: targetArray[2].match(/code = (\w+)/)?.[1],
description: targetArray[2].match(/desc = (.+?) \(errno/)?.[1],
errno: targetArray[2].match(/\(errno (\d+)\)/)?.[1],
sqlstate: targetArray[2].match(/\(sqlstate (\w+)\)/)?.[1],
callerID: targetArray[2].match(/\(CallerID: (.+)\):/)?.[1],
sql: targetArray[2].match(/Sql: "(.+?)"/)?.[1].replace(/\`/g, "'"),
bindVars: targetArray[2].match(/BindVars: {(.+?)}/)?.[1],
};
} catch { }
return null;
}; |
Hey, thanks for opening this issue. For now, I think what @ImLunaHey suggests is probably the best option. I briefly had downtime to sketch out making error handling configurable looks like, but ran into the problem of handling returned errors within transactions. If it was configurable, the errors could only be returned from direct |
yea I see, nothing urgent |
Thanks for this great library, it's fantastic to be able to query directly from Cloudflare Pages 🥳
Based on my experiments so far I feel like the library is pretty silent regarding errors, instead of returning or throwing anything it just does nothing, for example inserting a record with an existing id twice, only the first time shows the result of the query, second time nothing happens.
Personally I definitely prefer that it doesn't throw but it'd be really helpful if it could return errors, so I could react accordingly.
Edit: just stumbled upon #62 😅 though as stated I'd prefer the former returning errors instead of throwing, or the option to configure this, in my case it does nothing where I expect some form of information.
The text was updated successfully, but these errors were encountered: