> For the complete documentation index, see [llms.txt](https://demystifyfp.gitbook.io/fstoolkit-errorhandling/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/taskresult/transforms/ofasync.md).

# ofAsync

Namespace: `FsToolkit.ErrorHandling`

Transforms an `Async<'T>` into a `Task<Result<'T, exn>>`.

## Function Signature

```fsharp
Async<'T> -> Task<Result<'T, exn>>
```

## Examples

### Example 1

```fsharp
let result = TaskResult.ofAsync (async { return 42 })
// task { return Ok 42 }
```

### Example 2

```fsharp
let result = TaskResult.ofAsync (async { return System.Exception("error") })
// task { return Error (System.Exception("error")) }
```
