> ## Documentation Index
> Fetch the complete documentation index at: https://docs.crxbase.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Error Handling

> Handle errors thrown by the library

When an error occurs, the library throws a standard JavaScript `Error`.

Use `error.name` to determine the error type and handle it accordingly.

Match `error.name` against the values in the table below whenever you need to handle a specific failure in your app.

You can handle errors using a try-catch block as follows:

```typescript theme={null}
import { Client } from "@crxbase/payments";

const client = new Client("your_project_id");

try {
	const user = await client.getUser();
	// use the result
} catch (error: any) {
	if (error?.name === "unauthorized") {
		alert("You are not logged in. Please log in.");
		client.openLoginPage();
	} else {
		console.error("An unexpected error occurred:", error);
	}
}
```

### Errors

Below are the string values you can match against `error.name`:

| Name                | Description                                         |
| ------------------- | --------------------------------------------------- |
| `invalid_input`     | Invalid input provided.                             |
| `plan_not_found`    | No plan found for this user.                        |
| `project_not_found` | The specified project was not found.                |
| `rate_limited`      | Too many requests. Please wait before trying again. |
| `unauthorized`      | You must be logged in.                              |
| `unknown`           | Something went wrong. Please try again later.       |
