const result = try$(() => {
throw new Error("error");
});
// result is an Err with the error "error";
const result: Promise<Result<number, string>> = try$(Promise.resolve(1));
// result is an Ok with the value 1;
Try to run a function and return a result.
If the function throws an error, it will be caught and returned as an Err.
const result = try$(() => {
throw new Error("error");
});
// result is an Err with the error "error";
const result: Promise<Result<number, string>> = try$(Promise.resolve(1));
// result is an Ok with the value 1;
Try to run a function and return a result.
If the function throws an error, it will be caught and returned as an Err.
const result = try$(() => {
throw new Error("error");
});
// result is an Err with the error "error";
const result: Promise<Result<number, string>> = try$(Promise.resolve(1));
// result is an Ok with the value 1;
Try to run a function and return a result.
If the function throws an error, it will be caught and returned as an Err.
const result = try$(() => {
throw new Error("error");
});
// result is an Err with the error "error";
const result: Promise<Result<number, string>> = try$(Promise.resolve(1));
// result is an Ok with the value 1;
Try to run a function and return a result.
If the function throws an error, it will be caught and returned as an
Err.