Skip to main content
Docs

Errors

The Errors type is used to access the errors that occurred during the last API request when building custom sign-in and sign-up flows.

interface Errors {
  fields: FieldErrors
  raw: ClerkError[] | null
  global: ClerkGlobalHookError[] | null
}
  • Name
    fields
    Type
    FieldErrors
    Description

    The collection of possible errors on known fields.

  • Name
    raw
    Type
    ClerkError[] | null
    Description

    The raw, unparsed errors from the Clerk API. For example, if the error is an instance of ClerkAPIResponseError, this field will contain the ClerkAPIResponseError instance, while fields will contain the parsed errors associated with the fields that caused the error.

  • Name
    global
    Type
    ClerkGlobalHookError | null
    Description

    Parsed errors that are not related to any specific field.

  • Name
    firstName
    Type
    FieldError | null
    Description

    The error for the first name field.

  • Name
    lastName
    Type
    FieldError | null
    Description

    The error for the last name field.

  • Name
    emailAddress
    Type
    FieldError | null
    Description

    The error for the email address field.

  • Name
    identifier
    Type
    FieldError | null
    Description

    The error for the identifier field.

  • Name
    phoneNumber
    Type
    FieldError | null
    Description

    The error for the phone number field.

  • Name
    password
    Type
    FieldError | null
    Description

    The error for the password field.

  • Name
    username
    Type
    FieldError | null
    Description

    The error for the username field.

  • Name
    code
    Type
    FieldError | null
    Description

    The error for the code field.

  • Name
    captcha
    Type
    FieldError | null
    Description

    The error for the captcha field.

  • Name
    legalAccepted
    Type
    FieldError | null
    Description

    The error for the legal accepted field.

  • Name
    code
    Type
    string
    Description

    The error code of the error, returned by the Clerk API.

  • Name
    message
    Type
    string
    Description

    The error message of the error, returned by the Clerk API.

  • Name
    longMessage?
    Type
    string
    Description

    The long error message of the error, returned by the Clerk API.

ClerkGlobalHookError

Represents an error that occurred during the last API request, but is not related to any specific field. Is an instance of a ClerkError, and can also be an instance of a superclass of ClerkError, such as ClerkAPIResponseError or ClerkRuntimeError.

  • Name
    isClerkApiResponseError
    Type
    () => boolean
    Description

    A function that returns true if the error is an instance of ClerkAPIResponseError, false otherwise. Will also narrow down the type to ClerkAPIResponseError.

  • Name
    isClerkRuntimeError
    Type
    () => boolean
    Description

    A function that returns true if the error is an instance of ClerkRuntimeError, false otherwise. Will also narrow down the type to ClerkRuntimeError.

ClerkError

Type used for all errors generated by the Clerk SDK.

  • Name
    message
    Type
    string
    Description

    A message that describes the error. This is typically intented to be showed to the developers. It should not be shown to the user or parsed directly as the message contents are not guaranteed to be stable - use the code property instead.

  • Name
    code
    Type
    string
    Description

    A machine-stable code that identifies the error.

  • Name
    longMessage?
    Type
    string
    Description

    A user-friendly message that describes the error and can be displayed to the user. This message defaults to English but can be usually translated to the user's language by matching the code property to a localized message.

  • Name
    cause?
    Type
    Error
    Description

    The cause of the error, typically an Error instance that was caught and wrapped by the Clerk error handler.

  • Name
    docsUrl?
    Type
    string
    Description

    A URL to the documentation for the error.

Feedback

What did you think of this content?

Last updated on