> For AI agents: the complete documentation index is available at /byethrow/llms.txt, the full documentation bundle is available at /byethrow/llms-full.txt.

# Function: inspectError()

Executes a side effect function on the error value of a [Result](/byethrow/api/types/Result.Result.md) or [ResultAsync](/byethrow/api/types/Result.ResultAsync.md),
without modifying the original result. This is useful for debugging, logging, or performing
other side effects while maintaining the original value and error state.

## Type Param

**R1**

The input [Result](/byethrow/api/types/Result.Result.md) or [ResultAsync](/byethrow/api/types/Result.ResultAsync.md).

## Type Param

**R2**

The return type of the inspection function.

## Examples

**Failure Case**

```ts
import { Result } from '@praha/byethrow';

const result = Result.pipe(
  Result.fail('error'),
  Result.inspectError((error) => console.log('Debug error:', error)),
);
// Console output: "Debug error: error"
// Result: { type: 'Failure', error: 'error' }
```

**Success Case**

```ts
import { Result } from '@praha/byethrow';

const result = Result.pipe(
  Result.succeed(42),
  Result.inspectError((error) => console.log('Debug error:', error)),
);
// No console output
// Result: { type: 'Success', value: 42 }
```

## See

[pipe](/byethrow/api/functions/Result.pipe.md) - It is recommended to use this function with the [pipe](/byethrow/api/functions/Result.pipe.md) function for better readability and composability.

## Call Signature

> **inspectError**\<`R1`, `R2`>(`fn`): (`result`) => [`ResultFor`](/byethrow/api/types/Result.ResultFor.md)\<`R1` | `R2`, [`InferSuccess`](/byethrow/api/types/Result.InferSuccess.md)\<`R1`>, [`InferFailure`](/byethrow/api/types/Result.InferFailure.md)\<`R1`>>

### Type Parameters

#### R1

`R1` _extends_ [`ResultMaybeAsync`](/byethrow/api/types/Result.ResultMaybeAsync.md)\<`any`, `any`>

#### R2

`R2`

### Parameters

#### fn

(`a`) => `R2`

### Returns

(`result`) => [`ResultFor`](/byethrow/api/types/Result.ResultFor.md)\<`R1` | `R2`, [`InferSuccess`](/byethrow/api/types/Result.InferSuccess.md)\<`R1`>, [`InferFailure`](/byethrow/api/types/Result.InferFailure.md)\<`R1`>>

## Call Signature

> **inspectError**\<`F`>(`fn`): \<`R1`>(`result`) => [`ResultFor`](/byethrow/api/types/Result.ResultFor.md)\<`R1` | `ReturnType`\<`F`>, [`InferSuccess`](/byethrow/api/types/Result.InferSuccess.md)\<`R1`>, [`InferFailure`](/byethrow/api/types/Result.InferFailure.md)\<`R1`>>

### Type Parameters

#### F

`F` _extends_ (`a`) => `unknown`

### Parameters

#### fn

`F`

### Returns

\<`R1`>(`result`) => [`ResultFor`](/byethrow/api/types/Result.ResultFor.md)\<`R1` | `ReturnType`\<`F`>, [`InferSuccess`](/byethrow/api/types/Result.InferSuccess.md)\<`R1`>, [`InferFailure`](/byethrow/api/types/Result.InferFailure.md)\<`R1`>>
