handleCommonError<T> function

ApiException handleCommonError<T>(
  1. Object exception,
  2. StackTrace stacktrace
)

Handles common errors and returns the appropriate ApiException.

Implementation

ApiException handleCommonError<T>(Object exception, StackTrace stacktrace) {
  if (exception is FormatException ||
      exception.toString().contains('is not a subtype of')) {
    return ParseException(
      message: exception.toString(),
      stackTrace: stacktrace,
    );
  }
  return ServerException(
    message: exception.toString(),
    stackTrace: stacktrace,
  );
}