tryError Documentation

Function: fromThrown()
Function

```ts function fromThrown(cause, context?): TryError; ``` Defined in: [errors.ts:780](https://github.com/oconnorjohnson/try-error/blob/e3ae0308069a4fba073f4543d527ad76373db795/src/errors.ts#L780) Create a TryError from a thrown value with automatic type detection

tryError API Documentation v0.0.1-alpha.1


tryError API Documentation / fromThrown

Function: fromThrown()

function fromThrown(cause, context?): TryError;

Defined in: errors.ts:780

Create a TryError from a thrown value with automatic type detection

Parameters

cause

unknown

The thrown value

context?

Record<string, unknown>

Optional additional context

Returns

TryError

A TryError with appropriate type based on the cause

Example

try {
  riskyOperation();
} catch (error) {
  return fromThrown(error);
}