# Error

<a id="error"></a>

# Error

```cpp
#include <icy/error.h>

struct Error
```

[Defined in src/base/include/icy/error.h:32](https://github.com/auscaster/icey/blob/main/src/base/include/icy/error.h#L32)

Basic error type.

Errors contain an error code, message, and exception pointer.

## Friends

| Name | Description |
|------|-------------|
| [`operator<<`](#operator-27) `inline` |  |

---

<a id="operator-27"></a>

### operator<<

`inline`

```cpp
friend inline std::ostream & operator<<(std::ostream & stream, const Error & err)
```

[Defined in src/base/include/icy/error.h:80](https://github.com/auscaster/icey/blob/main/src/base/include/icy/error.h#L80)

## Public Attributes

| Return | Name | Description |
|--------|------|-------------|
| `int` | [`err`](#err)  |  |
| `std::string` | [`message`](#message)  |  |
| `std::exception_ptr` | [`exception`](#exception)  |  |

---

<a id="err"></a>

### err

```cpp
int err
```

[Defined in src/base/include/icy/error.h:34](https://github.com/auscaster/icey/blob/main/src/base/include/icy/error.h#L34)

---

<a id="message"></a>

### message

```cpp
std::string message
```

[Defined in src/base/include/icy/error.h:35](https://github.com/auscaster/icey/blob/main/src/base/include/icy/error.h#L35)

---

<a id="exception"></a>

### exception

```cpp
std::exception_ptr exception
```

[Defined in src/base/include/icy/error.h:36](https://github.com/auscaster/icey/blob/main/src/base/include/icy/error.h#L36)

## Public Methods

| Return | Name | Description |
|--------|------|-------------|
|  | [`Error`](#error-1) `inline` | Default constructor; initializes all fields to a no-error state. |
|  | [`Error`](#error-2) `inline` | Constructs an error with the given message string. |
|  | [`Error`](#error-3) `inline` | Constructs an error with the given C string message. |
| `bool` | [`any`](#any) `const` `inline` | Returns true if any error condition is set (non-zero code, non-empty message, or exception). |
| `void` | [`reset`](#reset-1) `inline` | Clears all error fields, resetting to a no-error state. |
| `void` | [`rethrow`](#rethrow) `inline` | Re-throws the stored exception pointer if one is set. Has no effect if `exception` is null. |

---

<a id="error-1"></a>

### Error

`inline`

```cpp
inline Error()
```

[Defined in src/base/include/icy/error.h:39](https://github.com/auscaster/icey/blob/main/src/base/include/icy/error.h#L39)

Default constructor; initializes all fields to a no-error state.

---

<a id="error-2"></a>

### Error

`inline`

```cpp
inline Error(const std::string & msg)
```

[Defined in src/base/include/icy/error.h:43](https://github.com/auscaster/icey/blob/main/src/base/include/icy/error.h#L43)

Constructs an error with the given message string.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `msg` | `const std::string &` | Human-readable error description. |

---

<a id="error-3"></a>

### Error

`inline`

```cpp
inline Error(const char * msg)
```

[Defined in src/base/include/icy/error.h:51](https://github.com/auscaster/icey/blob/main/src/base/include/icy/error.h#L51)

Constructs an error with the given C string message.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `msg` | `const char *` | Human-readable error description. |

---

<a id="any"></a>

### any

`const` `inline`

```cpp
inline bool any() const
```

[Defined in src/base/include/icy/error.h:59](https://github.com/auscaster/icey/blob/main/src/base/include/icy/error.h#L59)

Returns true if any error condition is set (non-zero code, non-empty message, or exception). 
#### Returns
True if an error is present.

---

<a id="reset-1"></a>

### reset

`inline`

```cpp
inline void reset()
```

[Defined in src/base/include/icy/error.h:65](https://github.com/auscaster/icey/blob/main/src/base/include/icy/error.h#L65)

Clears all error fields, resetting to a no-error state.

---

<a id="rethrow"></a>

### rethrow

`inline`

```cpp
inline void rethrow()
```

[Defined in src/base/include/icy/error.h:74](https://github.com/auscaster/icey/blob/main/src/base/include/icy/error.h#L74)

Re-throws the stored exception pointer if one is set. Has no effect if `exception` is null.
