handleError method
Implementation
handleError(Response? holdRes, Exception e,
[WebServiceExceptionType? type]) async {
if (e is WebServiceException) throw raiseError(holdRes, e);
var res = e is WebResponseException ? e.response : holdRes!;
// if (res.bodyUsed)
// throw this.raiseError(res, createErrorResponse(res.status, res.statusText, type));
var webEx = WebServiceException()
..statusCode = res.statusCode
..statusDescription = res.reasonPhrase
..type = type;
try {
String str = res.body;
if (!isJsonObject(str)) {
webEx.responseStatus = createErrorResponse(res.statusCode.toString(),
res.reasonPhrase ?? res.statusCode.toString(), type)
.responseStatus;
} else {
var jsonObj = json.decode(str);
webEx.responseStatus = createResponseStatus(jsonObj);
}
} on Exception catch (e, trace) {
Log.warn("handleError(): $e\n$trace");
webEx.innerException = e;
}
throw raiseError(res, webEx);
}