guardExceptionSync<T extends Object?, E extends Exception> static method

Result<T, E> guardExceptionSync<T extends Object?, E extends Exception>(
  1. T block()
)

Executes a synchronous function, catching only Exception types.

A convenience method that constrains the error type to Exception rather than accepting any Object. Use this when you want Error values to propagate uncaught.

Example:

final result = Result<int, FormatException>.guardExceptionSync(
  () => int.parse(input),
);

Implementation

static Result<T, E> guardExceptionSync<
  T extends Object?,
  E extends Exception
>(T Function() block) => Result<T, E>.guardSync(block);