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); const serializer = new this.serializerConstructor(objConstructor);
return serializer.deserialize(obj); return serializer.deserialize(obj);
} else { } else {
console.warn('cannot deserialize type ' + type);
return null; return null;
} }
} else { } else {
console.warn('cannot deserialize type ' + type);
return null; return null;
} }
} }
@@ -142,7 +144,8 @@ export abstract class BaseResponseParsingService {
} else { } else {
dataJSON = JSON.stringify(data); 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); this.objectCache.add(co, hasValue(request.responseMsToLive) ? request.responseMsToLive : this.EnvConfig.cache.msToLive.default, request.uuid);
} }