-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
I don't see a way to achieve this without adding a method to ResultSharp. Something like...
public static async ValueTask<Result<T, E>> TryAsync<T, E>(Func<Task<T>> fn) where E : Exception
{
try
{
var value = await fn();
return Result<T, E>.Ok(value);
}
catch (E exception)
{
return Result<T, E>.Err(exception);
}
}
public static ValueTask<Result<T, Exception>> TryAsync<T>(Func<Task<T>> fn) =>
TryAsync<T, Exception>(fn);
Metadata
Metadata
Assignees
Labels
No labels