Commit 5225ab8b authored by Tobinsk's avatar Tobinsk

Merge branch '3-json-transform-error' into 'master'

Catch json transform error

Closes #3

See merge request !4
parents 32f1f9b4 61fe6c81
......@@ -24,8 +24,8 @@ class DodisNormalizerTransformer extends Transform {
* @private
*/
public _transform(chunk, encoding, callback) {
const data = JSON.parse(chunk.res.body);
try {
const data = JSON.parse(chunk.res.body);
const res = {
id: data.data.id.toString(),
provider: 'dodis',
......@@ -39,6 +39,10 @@ class DodisNormalizerTransformer extends Transform {
return callback(null, res);
} catch (error) {
if(error.name === 'SyntaxError') {
this.logger.warn(`Could not parse ${chunk.url}`);
return callback(null);
}
this.logger.error(error);
return callback(error);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment