getExceptionFromDefaultResult function
Returns the BreakingBadQuotesException by checking the DefaultResult.
Like if any error happens due to invalid input to the request.
Implementation
BreakingBadQuotesException getExceptionFromDefaultResult(DefaultResult result) {
if (result.status == 400 && result.message == 'Invalid Arguments') {
return InvalidArgumentsException();
}
if (result.status == 403 &&
result.message!.startsWith('Use of the history Delete API')) {
return MethodDisabledException(result.message!);
}
if (result.status == 403 && result.message == 'Forbidden') {
return ForbiddenException(result.message!);
}
if (result.message?.isNotEmpty ?? false) {
return BreakingBadQuotesException('Error: ${result.message}');
}
return BreakingBadQuotesException(Constants.unknownError);
}