Skip to content
exwave.Docs

Errors

When something goes wrong, Exwave Auth gives you an ExwaveAuthError. Its code says what happened.

  • The client’s calls, such as auth.signIn(), throw it.
  • The hooks don’t throw. They put the error in error, and a sentence you can show in message.

Use error.code to decide what to do:

import { isExwaveAuthError } from "@exwave-nexus/auth";
import { describeError } from "@exwave-nexus/auth/messages";
try {
await auth.signIn({ login, password });
} catch (error) {
if (isExwaveAuthError(error) && error.code === "email_not_verified") {
// Offer to send a new verification link.
} else {
alert(describeError(error)); // The error as a sentence you can show.
}
}

describeError() turns any error into a sentence, in English or in your own words.

These usually mean something in your setup needs fixing:

  • invalid_redirect_to: the page’s address isn’t allowed. Add it, such as http://localhost:3000, to the Redirect URLs in Nexus → Auth → Settings.
  • site_url_required: an email had no address to link to. Add your website’s address as the Site URL in Nexus → Auth → Settings.
  • managed_auth_not_enabled: Auth is off for this platform. In Nexus → Auth, select Turn on Auth.
  • invalid_publishable_key: the key in .env.local isn’t an exw_pk_… key. Copy it again from Nexus → Auth, then restart the dev server.
  • network_error: the request never reached the server. If you use the local mock, check that it’s running.
Code What happened Message shown by default
invalid_credentials The login or the password is wrong. Wrong email, username or password.
email_not_verified Someone tried to sign in before opening the verification link. Verify your email first: open the link we sent you.
player_locked The account was locked in Nexus. Its sessions end with the reason account_locked. This account is locked. Contact support.
email_taken Someone tried to sign up with an email that’s already used. An account already uses this email. Sign in instead?
username_taken Someone tried to sign up with a username that’s already used. This username is taken.
weak_password The password breaks your platform’s rules. error.failedRules lists which ones. Your password needs … (the rules it misses)
invalid_code The email link was already used, or has expired. This link has expired or was already used.
sign_up_disabled Sign-up is turned off in Nexus. Sign-up is closed.
invalid_redirect_to The page’s address isn’t your Site URL or one of your Redirect URLs. This site’s address isn’t allowed yet: add it to Redirect URLs in Nexus → Auth → Settings.
site_url_required A verification or password reset email had no address to link to: the request didn’t give one, and your platform has no Site URL. Email links need a Site URL: set one in Nexus → Auth → Settings.
rate_limited There were too many attempts. error.retryAfter says how many seconds to wait. Too many attempts. Try again in …
invalid_refresh_token The session expired, or ended elsewhere, for example after signing out everywhere or a password reset. Your session ended. Sign in again.
managed_auth_not_enabled Auth is turned off for this platform. Auth is turned off for this platform in Nexus.
managed_auth_unavailable Exwave Auth can’t answer right now. Sign-in is unavailable right now. Try again in a moment.
Code What happened
network_error The request never reached the server. error.status is 0.
invalid_publishable_key The key isn’t an exw_pk_… key.
not_signed_in A call needs someone to be signed in, and nobody is.
invalid_token A player access token didn’t pass verifyPlayerAccessToken.
forbidden Another website sent a request to your /api/exwave routes.

After someone is signed out, useExwave().signOutReason says why, for five minutes. On a Next.js server, use exwave.getSignOutReason().

Reason What happened
signed_out They signed out on this device.
signed_out_everywhere They signed out on every device, from this one.
invalid_refresh_token The session expired, or ended elsewhere.
account_locked The account was locked in Nexus.

describeSignOut(reason), from @exwave-nexus/auth/messages, gives you the sentence to show, and a tone: "error", "info" or "ok".