From 8f429700dad00bc41b702092e0d794e71e9dc2e4 Mon Sep 17 00:00:00 2001 From: Colin Date: Tue, 6 Feb 2018 15:41:33 -0500 Subject: [PATCH] Global require.on error handler --- index.html | 3 +++ src/JBrowse/Browser.js | 6 ------ src/JBrowse/View/Track/CanvasFeatures.js | 6 ------ 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/index.html b/index.html index 13e842fe10..82254b9fef 100644 --- a/index.html +++ b/index.html @@ -109,6 +109,9 @@ // create a JBrowse global variable holding the JBrowse instance JBrowse = new Browser( config ); + require.on('error', function(error) { + JBrowse.fatalError('Failed to load resource: '+error.info[0]); + }); }); diff --git a/src/JBrowse/Browser.js b/src/JBrowse/Browser.js index 09b566e10c..5814e44da0 100644 --- a/src/JBrowse/Browser.js +++ b/src/JBrowse/Browser.js @@ -320,15 +320,9 @@ initPlugins: function() { return new Deferred(); }); - var handler = require.on("error", function(error) { - console.error(error); - deferred.reject('A resource failed to load '+error.src + ':' + error.info[0]); - }); - // fire the "all plugins done" deferred when all of the plugins are done loading (new DeferredList( pluginDeferreds )) .then( function() { - handler && handler.remove(); deferred.resolve({success: true}); }); diff --git a/src/JBrowse/View/Track/CanvasFeatures.js b/src/JBrowse/View/Track/CanvasFeatures.js index e5821b5565..549809151e 100644 --- a/src/JBrowse/View/Track/CanvasFeatures.js +++ b/src/JBrowse/View/Track/CanvasFeatures.js @@ -322,14 +322,8 @@ return declare( var thisB = this; this.glyphsBeingLoaded[glyphClassName] = [callback]; - var handler = require.on("error", function(error) { - console.error(error); - errorCallback('A resource failed to load '+error.src + ':' + error.info[0]); - }); require( [glyphClassName], function( GlyphClass ) { - - handler && handler.remove(); // if this require came back after we are already destroyed, just ignore it if( thisB.destroyed ) return;