From e0104e35893b6a2f837af7bfa2dea9a562646c49 Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Tue, 28 Nov 2017 13:24:36 +0100 Subject: [PATCH] chore(Viewer): handle import error outside try/catch --- lib/Viewer.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/Viewer.js b/lib/Viewer.js index 07ba5b7f..0c691e34 100644 --- a/lib/Viewer.js +++ b/lib/Viewer.js @@ -22,7 +22,7 @@ var Diagram = require('diagram-js'), var inherits = require('inherits'); -var Importer = require('./import/Importer'); +var importBpmnDiagram = require('./import/Importer').importBpmnDiagram; function checkValidationError(err) { @@ -292,6 +292,8 @@ Viewer.prototype.saveSVG = function(options, done) { Viewer.prototype.importDefinitions = function(definitions, done) { + var err; + // use try/catch to not swallow synchronous exceptions // that may be raised during model parsing try { @@ -305,12 +307,13 @@ Viewer.prototype.importDefinitions = function(definitions, done) { this._definitions = definitions; // perform graphical import - Importer.importBpmnDiagram(this, definitions, done); + return importBpmnDiagram(this, definitions, done); } catch (e) { - - // handle synchronous errors - done(e); + err = e; } + + // handle synchronous errors + return done(err); }; Viewer.prototype.getModules = function() {