Skip to content

No way to display cusom error messages #800

Open
@nicitaacom

Description

@nicitaacom

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
    Yes because previously I did smth like this and it worked
if ((error as { code?: string })?.code === "23505") {
        displayResponseMessage(<p className="text-danger">This user already exists</p>)
      }

Describe the bug

No way to handle login/register errors with
I use Next 13.5 + TypeScript

} catch (error: unknown) {
      if (error instanceof AuthError) {
        if (error.message.includes("duplicate key value violates unique constraint")) {
          displayResponseMessage(<p className="text-danger">User with this username/email already exists.</p>)
        } else {
          displayResponseMessage(<p className="text-danger">{error.message}</p>)
        }
        console.error("Login with email - ", error)
      } else {
        displayResponseMessage(
          <p className="text-danger">
            An unknown error occurred - contact admin
            <Button href="https://t.me/nicitaacom" variant="link">
              here
            </Button>
          </p>,
        )
        console.error("Unknown error - ", error)
      }
    }

To Reproduce

Its not minimal example becasue codesadbox doesn't work in vs code and I have error making codesandbox as public (support ignores me) - to do something with issue just create supabase example how to display custom error messages when login (you can make sure that its doesn't work if you make git cline and pnpm dev - then try to signUp with [email protected] email (this email already exist and it thow no relevat/customizable error message)
https://github.com/nicitaacom/23_store/blob/development/app/components/ui/Modals/AuthModal/AuthModal.tsx
173 line

  1. Go to github repository
  2. Scroll down to 173 line
  3. How display custom error from supabase here?

Expected behavior

When I write code above - nothing happening but in dev tools console I got the error
image

System information

  • Version of supabase-js:
    "next": "13.5.3",
    "@supabase/auth-helpers-nextjs": "^0.8.1",
    "@supabase/supabase-js": "^2.36.0",
  • Version of Node.js: 18.13.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions