exceptionHandlerWithMessage function

String exceptionHandlerWithMessage({
  1. required BuildContext context,
  2. required dynamic e,
})

Handle Exception with returned message

Implementation

String exceptionHandlerWithMessage(
    {required BuildContext context, required dynamic e}) {
  if (e is SocketException) {
    return '😌 You do not have access to the internet';
  } else if (e is TimeoutException) {
    return 'There seems to be a connection issue. Please try again shortly';
  } else {
    // On any other exception
    return 'Please try again shortly';
  }
}