Refusing to cache an object which can't be parsed

This commit is contained in:
Ben Bosman
2020-03-05 11:01:19 +01:00
parent 01231ef105
commit 373acc6c82

View File

@@ -117,10 +117,12 @@ export abstract class BaseResponseParsingService {
const serializer = new this.serializerConstructor(objConstructor);
return serializer.deserialize(obj);
} else {
console.warn('cannot deserialize type ' + type);
return null;
}
} else {
console.warn('cannot deserialize type ' + type);
return null;
}
}
@@ -142,7 +144,8 @@ export abstract class BaseResponseParsingService {
} else {
dataJSON = JSON.stringify(data);
}
throw new Error(`Can't cache incomplete ${type}: ${JSON.stringify(co)}, parsed from (partial) response: ${dataJSON}`);
console.warn(`Can't cache incomplete ${type}: ${JSON.stringify(co)}, parsed from (partial) response: ${dataJSON}`);
return;
}
this.objectCache.add(co, hasValue(request.responseMsToLive) ? request.responseMsToLive : this.EnvConfig.cache.msToLive.default, request.uuid);
}