manageLinkException method
Handles exceptions from a QueryResult.
This method checks the exception in the QueryResult and throws an appropriate
exception based on the type of error:
-
If the exception is a TimeoutException, it rethrows it.
-
If the exception is an
HttpLinkParserExceptionwith status code429or503, it throws an ArchethicTooManyRequestsException. -
For other exceptions, it throws an ArchethicConnectionException.
-
result: TheQueryResultto check for exceptions.
Implementation
void manageLinkException(QueryResult result) {
final exception = result.exception?.linkException;
if (exception == null) return;
if (exception is UnknownException) {
if (exception.originalException is TimeoutException) {
throw TimeoutException(exception.message);
}
}
if (exception is HttpLinkParserException) {
if (exception.response.statusCode == 429) {
throw const ArchethicTooManyRequestsException();
}
if (exception.response.statusCode == 503) {
throw const ArchethicServiceUnavailableException();
}
}
throw ArchethicConnectionException(exception.toString());
}