diff --git a/packages/mars-build/src/compiler/file/compiler.js b/packages/mars-build/src/compiler/file/compiler.js index ab930e1c..46e4971a 100644 --- a/packages/mars-build/src/compiler/file/compiler.js +++ b/packages/mars-build/src/compiler/file/compiler.js @@ -98,12 +98,12 @@ exports.gulpPlugin = function (options) { return cb(); } if (file.isBuffer()) { - try { - compile(file, options).then(_ => cb(null, file)); - } - catch (e) { - log.error('[COMPILE ERROR]:', e); - } + compile(file, options) + .then(_ => cb(null, file)) + .catch(err => { + log.error('[COMPILE ERROR]:', err); + cb(null, file); + }); return; } // for other file type diff --git a/packages/mars-build/src/gulp-mars-base.js b/packages/mars-build/src/gulp-mars-base.js index f3516577..0a54ca49 100644 --- a/packages/mars-build/src/gulp-mars-base.js +++ b/packages/mars-build/src/gulp-mars-base.js @@ -69,12 +69,12 @@ function gulpPlugin(opt = {dest: './dist'}, compilers) { return cb(); } if (file.isBuffer()) { - try { - compile(file, opt, compilers).then(_ => cb(null, file)); - } - catch (e) { - log.error('[COMPILE ERROR]:', e); - } + compile(file, opt, compilers) + .then(_ => cb(null, file)) + .catch(err => { + log.error('[COMPILE ERROR]:', err); + cb(null, file); + }); } }); return stream;