handle static method

AppError handle(
  1. Exception exception
)

Implementation

static AppError handle(Exception exception) {
  if (exception is TimeoutException) {
    return AppError(error: 'Request timed out.', exception: exception);
  } else if (exception is SocketException) {
    return AppError(error: 'No internet connection.', exception: exception);
  } else if (exception is FormatException) {
    return AppError(error: 'Invalid response format.', exception: exception);
  } else if (exception is HttpException) {
    return AppError(
      error: _mapStatusCodeToMessage(exception.statusCode),
      exception: exception,
    );
  } else {
    return AppError(error: 'Something went wrong.', exception: exception);
  }
}