tryAndCatch<RT extends Object, ET extends Exception> static method
RT...return type
ET...exception type
exception を throw する可能性のある function を実行し, もし exception が throw された 場合 その exception を catch し 返す syntax sugar.
Implementation
static Result<RT, ET> tryAndCatch<
RT extends Object
,ET extends Exception
>(
RT Function() tryAction,
) {
final classLocation = Result;
const functionLocation = 'tryAndCatch';
Map<String, dynamic> monitor = {};
Map<String, dynamic> debug = {};
List<Log> histories = [];
try {
final value = tryAction();
return Success(value, classLocation, functionLocation, monitor, debug, histories);
} on ET catch (e) {
return Failure(e, classLocation, functionLocation, monitor, debug, histories);
}
}