> For the complete documentation index, see [llms.txt](https://funkcia.lukemorales.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://funkcia.lukemorales.io/modules/exceptions.md).

# Exceptions

The Exceptions module provides a set of custom error types used throughout Funkcia for type-safe error handling.

### Base Error Class

#### TaggedError

{% hint style="success" %}
Create tagged errors using this function to enforce \_tag identifiers, making error handling easier in your application.
{% endhint %}

A function that creates a tagged error constructor. Errors created with this function have a `_tag` property for identification.

```typescript
import { TaggedError } from 'funkcia/exceptions';

class UserNotFoundError extends TaggedError('UserNotFound') {
  constructor(message?: string) {
    super(message);
  }
}
```

#### TaggedError.is

Checks if a value is a tagged error.

```typescript
import { TaggedError } from 'funkcia/exceptions';

if (TaggedError.is(error)) {
  // error is a TaggedError
}
```

### General Exceptions

#### Panic

Thrown when callbacks throw inside `Option` or `Result` operations. Represents a defect in your code – just like Rust’s `panic!()`.

{% hint style="info" %}
If a `Panic` is thrown, a deviation between your software’s actual behavior and it’s expected behavior exists, causing incorrect results. It is a defect to fix, not an error to handle.
{% endhint %}

#### UnhandledException

A wrapper for errors caught in try/catch blocks in a `Result`.

#### NoValueError

Error used when a nullable value is converted to a Result and is `null | undefined`.

#### FailedPredicateError

Error used when a predicate check fails in a Result chain.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://funkcia.lukemorales.io/modules/exceptions.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
