# Errors

## Description

Errors inheriting from `Error` objects will be thrown, and custom error properties are described in the `Response` below

See more details for [Error objects](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error)

## Response

| Variable    | Type             | Description                                   |
| ----------- | ---------------- | --------------------------------------------- |
| `from`      | `"StartrailSdk"` | To identify where the error comes from        |
| `errorCode` | `ErrorCode`      | To identify the error type for error handling |

## ErrorCode

Followings are the errors to be returned. Frontend can catch and handle it accordingly for better UX.

<details>

<summary>AUTH0_VERIFY_EMAIL</summary>

**What:**

Immediately after signup is submitted with Email Password by a user, this error is thrown.

**Action to take:**

You can customize the UI/UX to align with your project's specific plans and requirements. How you choose to handle this customization depends on the unique needs of your project.

</details>

<details>

<summary>METADATA_VALIDATION_FAILED</summary>

**What:**

Metadata validation fails duet to schema validation.

**Action to take:**

Revise the metadata object itself based on the error message.

</details>

<details>

<summary>STARTRAIL_API_ERROR</summary>

**What:**

Error occurs in StartrailAPI.

**Action to take:**

Check error message to identify the content.

</details>

<details>

<summary>TORUS_USER_REJECT_WALLET_REQUEST</summary>

**What:**

The user closes the confirmation popup presented for signing.

**Action to take:**

You can customize the UI/UX to align with your project's specific plans and requirements. How you choose to handle this customization depends on the unique needs of your project.

</details>

<details>

<summary>WALLET_NOT_INITIALIZED</summary>

**What:**

After logging out from the SDK, the wallet instance becomes undefined.

**Action to take:**

Call `new Startrail()` once again in your web-application.

</details>

<details>

<summary>WALLET_NOT_SUPPORTED</summary>

**What:**

Unsupported wallet is called. (Official MetaMask library calls Coinbase Wallet browser extension when it is activated)

**Action to take:**

Request end-users to switch your wallet.

</details>

<details>

<summary>WALLET_EOA_NOT_MATCH</summary>

**What:**

It is not possible to prevent end-users from switching their EOA on Metamask even after logging in, which can potentially lead to a scenario where the EOA used for signing, e.g., for issuing SRR, is different from the one they initially logged into the web application.

**When**

When SDK calls StartrailAPI

**Action to take:**

Request to switch back to the EOA with which the user originally logged in.

</details>

<details>

<summary>WALLET_NOT_FOUND</summary>

**What:**

The wallet does not open because it has not been activated (unlocked) in your browser extension.

**Action to take:**

Request end-users to activate or unlock your wallet.

</details>

<details>

<summary>WALLET_NOT_SUPPORT_FUNCTION</summary>

**What:**

Some functions are not supported for particular wallets. eg. `overwriteConfig()` or `switchLanguage()` are not supported in Metamask.

**Action to take:**

It depends on frontend developers

</details>

## Response Example

###

Example

```
{
	from: 'StartrailSdk',
	errorCode: 'TORUS_USER_REJECT_WALLET_REQUEST',
	message: 'Torus Message Signature: User denied message signature.',

}
```
