tryCatch function

dynamic tryCatch(
  1. BuildContext context, {
  2. required void action(),
  3. void socketException(
    1. SocketException,
    2. StackTrace
    )?,
  4. void formatException(
    1. FormatException,
    2. StackTrace
    )?,
  5. void platformException(
    1. PlatformException,
    2. StackTrace
    )?,
  6. void exception(
    1. Exception,
    2. StackTrace
    )?,
  7. void error(
    1. Error,
    2. StackTrace
    )?,
  8. void otherCatch(
    1. dynamic,
    2. StackTrace
    )?,
})

try catch function

Implementation

tryCatch(
  BuildContext context, {
  required void Function() action,
  void Function(SocketException, StackTrace)? socketException,
  void Function(FormatException, StackTrace)? formatException,
  void Function(PlatformException, StackTrace)? platformException,
  void Function(Exception, StackTrace)? exception,
  void Function(Error, StackTrace)? error,
  void Function(dynamic, StackTrace)? otherCatch,
}) async {
  try {
    action();
  } on SocketException catch (e, s) {
    if (socketException != null) socketException(e, s);
  } on FormatException catch (e, s) {
    if (formatException != null) formatException(e, s);
  } on PlatformException catch (e, s) {
    if (platformException != null) platformException(e, s);
  } on Exception catch (e, s) {
    if (exception != null) exception(e, s);
  } on Error catch (e, s) {
    if (error != null) error(e, s);
  } catch (e, s) {
    if (otherCatch != null) otherCatch(e, s);
  }
}