The type of the value returned by the function.
The type of the error that may be thrown, defaults to Error.
The types of the arguments to pass to the function.
Ok<T> if the function succeeds, or Err<E> if it throws.
// Parse JSON safely with arguments
const result = tryResult(JSON.parse, jsonString);
result.inspect(data => console.log('Parsed:', data))
.inspectErr(err => console.error('Invalid JSON:', err));
Executes a function and captures any thrown exception as an
Err. If the function executes successfully, returnsOkwith the result.Use this to convert traditional try-catch error handling to Result-based handling.
Similar to
Promise.try, this function accepts optional arguments that are passed to the function.