toApiException property
ApiException
get
toApiException
Convert DioException
to ApiException
Implementation
ApiException get toApiException {
return switch (type) {
DioExceptionType.badResponse => _handleBadResponse(response),
DioExceptionType.cancel => RequestCancelledException(
message: DioExtensionMessages.requestCancelled,
stackTrace: stackTrace,
),
DioExceptionType.connectionError => NetworkException(
message: message ?? DioExtensionMessages.networkError,
stackTrace: stackTrace,
),
DioExceptionType.connectionTimeout => TimeoutException(
message: DioExtensionMessages.unstableConnection,
stackTrace: stackTrace,
),
DioExceptionType.receiveTimeout ||
DioExceptionType.sendTimeout =>
TimeoutException(
message: DioExtensionMessages.requestTimeout,
stackTrace: stackTrace,
),
DioExceptionType.badCertificate => BadCertificateException(
message: DioExtensionMessages.badCertificateError,
stackTrace: stackTrace,
),
_ => ServerException(
message: message ?? DioExtensionMessages.unexpectedError,
stackTrace: stackTrace,
),
};
}