# Function: fail()

Creates a [Failure](../types/Result.Failure.md) result from a given error.
Automatically wraps the error in a `Promise` if it is asynchronous.

## Type Param

**E**

The type of the error to wrap.

## Examples

**Synchronous Usage**

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

const result = Result.fail('Something went wrong');
// Result.Result<never, string>
```

**Asynchronous Usage**

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

const result = Result.fail(Promise.resolve('Async error'));
// Result.ResultAsync<never, string>
```

**With No Value**

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

const result = Result.fail();
// Result.Result<never, void>
```

## See

[collect](./Result.collect.md) - For collect multiple Results into a single Result.

## Call Signature

> **fail**(): [`Result`](../types/Result.Result.md)\<`never`, `void`>

### Returns

[`Result`](../types/Result.Result.md)\<`never`, `void`>

## Call Signature

> **fail**\<`E`>(`error`): [`ResultFor`](../types/Result.ResultFor.md)\<`E`, `never`, `Awaited`\<`E`>>

### Type Parameters

#### E

`E`

### Parameters

#### error

`E`

### Returns

[`ResultFor`](../types/Result.ResultFor.md)\<`E`, `never`, `Awaited`\<`E`>>
