From 3d0b217743d4f7a3aa93856b07ef89a3467f8f87 Mon Sep 17 00:00:00 2001 From: LuanRT Date: Tue, 14 Jun 2022 17:54:31 -0300 Subject: [PATCH] fix: do not return `null` if a renderer is not found This caused the parser to return null when ads or renderers that are not implemented are present. --- lib/parser/contents/index.js | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/lib/parser/contents/index.js b/lib/parser/contents/index.js index 231d481c..f0f08e3c 100644 --- a/lib/parser/contents/index.js +++ b/lib/parser/contents/index.js @@ -106,14 +106,13 @@ class Parser { const keys = Object.keys(item); const classname = this.sanitizeClassName(keys[0]); - if (this.shouldIgnore(classname)) return; - - try { - const TargetClass = require('./classes/' + classname); - results.push(new TargetClass(item[keys[0]])); - } catch (err) { - this.formatError({ classname, classdata: item[keys[0]], err }); - return null; + if (!this.shouldIgnore(classname)) { + try { + const TargetClass = require('./classes/' + classname); + results.push(new TargetClass(item[keys[0]])); + } catch (err) { + this.formatError({ classname, classdata: item[keys[0]], err }); + } } } @@ -122,16 +121,16 @@ class Parser { const keys = Object.keys(data); const classname = this.sanitizeClassName(keys[0]); - if (this.shouldIgnore(classname)) return; - - try { - const TargetClass = require('./classes/' + classname); - return new TargetClass(data[keys[0]]); - } catch (err) { - this.formatError({ classname, classdata: data[keys[0]], err }); - return null; - } - } + if (!this.shouldIgnore(classname)) { + try { + const TargetClass = require('./classes/' + classname); + return new TargetClass(data[keys[0]]); + } catch (err) { + this.formatError({ classname, classdata: data[keys[0]], err }); + return null; + } + } + } } static formatError({ classname, classdata, err }) {