djbalin
djbalin5mo ago

Convex Auth: Error types for signUp/signIn

Hi, is there a way to know the possible types of errors that the signUp / signIn functions can throw? I want to disambiguate between error causes on the frontend. Specifically, I want to do something like:
try {
await signIn(...);
} catch (error) {
switch (error.type){
case InvalidId: alert("No user with that username found");
case InvalidPassword: alert("Incorrect password");
case TooManyAttempts: alert("Too many attempts to log in, try again in 5 minutes");
default: alert("Something went wrong, please try again")
}
try {
await signIn(...);
} catch (error) {
switch (error.type){
case InvalidId: alert("No user with that username found");
case InvalidPassword: alert("Incorrect password");
case TooManyAttempts: alert("Too many attempts to log in, try again in 5 minutes");
default: alert("Something went wrong, please try again")
}
2 Replies
Michal Srb
Michal Srb5mo ago
You can copy the implementation of the Password provider and customize it to throw ConvexErrors.
giray
giray5mo ago
@Michal Srb this should be implemented by the library, so I think it is a valid feature request. I came to this as well. The reason we are using 3rd party auth solutions is that we want to deal with internals as little as possible. Currently I get an error like on the image. It does not even give a pure user-friendly response to show directly on the page.
No description