From 4b99e432d63e7a0ce8ad8d2184232417853bfd2b Mon Sep 17 00:00:00 2001 From: eric thul Date: Sat, 5 Nov 2016 14:01:18 -0400 Subject: Wrapping reject values in Error objects --- src/Psc.js | 4 ++-- src/PscIde.js | 12 ++++++------ src/index.js | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Psc.js b/src/Psc.js index 3901eca..5954944 100644 --- a/src/Psc.js +++ b/src/Psc.js @@ -41,7 +41,7 @@ function compile(psModule) { cache.compilationFinished = true if (code !== 0) { cache.errors = stderr.join('') - reject(true) + reject(new Error('compilation failed')) } else { cache.warnings = stderr.join('') resolve(psModule) @@ -83,7 +83,7 @@ function bundle(options, cache) { compilation.on('close', code => { if (code !== 0) { cache.errors = (cache.errors || '') + stderr.join('') - return reject(true) + return reject(new Error('bundling failed')) } cache.bundle = stderr resolve(fs.appendFileAsync(options.bundleOutput, `module.exports = ${options.bundleNamespace}`)) diff --git a/src/PscIde.js b/src/PscIde.js index 9d6c1ff..c9d0cfa 100644 --- a/src/PscIde.js +++ b/src/PscIde.js @@ -38,7 +38,7 @@ function connect(psModule) { ideClient.stderr.on('data', data => { debug(data.toString()) cache.ideServer = false - reject(true) + reject(new Error('psc-ide-client failed')) }) ideClient.stdout.once('data', data => { debug(data.toString()) @@ -49,11 +49,11 @@ function connect(psModule) { resolve(psModule) } else { cache.ideServer = ideServer - reject(true) + reject(new Error('psc-ide-client failed')) } } else { cache.ideServer = false - reject(true) + reject(new Error('psc-ide-client failed')) } }) ideClient.stdin.resume() @@ -135,7 +135,7 @@ function rebuild(psModule) { if (res && !Array.isArray(res.result)) { return res.resultType === 'success' ? resolve(psModule) - : reject('psc-ide rebuild failed') + : reject(new Error('psc-ide rebuild failed')) } Promise.map(res.result, (item, i) => { @@ -153,10 +153,10 @@ function rebuild(psModule) { })) .then(() => request({ command: 'load' })) .then(resolve) - .catch(() => reject('psc-ide rebuild failed')) + .catch(() => reject(new Error('psc-ide rebuild failed'))) } cache.errors = compileMessages.join('\n') - reject('psc-ide rebuild failed') + reject(new Error('psc-ide rebuild failed')) } else { cache.warnings = compileMessages.join('\n') resolve(psModule) diff --git a/src/index.js b/src/index.js index c73fdd5..f3b2fde 100644 --- a/src/index.js +++ b/src/index.js @@ -125,7 +125,7 @@ module.exports = function purescriptLoader(source, map) { })) .catch(error => { cache.deferred[0].reject(error) - cache.deferred.slice(1).forEach(psModule => psModule.reject(true)) + cache.deferred.slice(1).forEach(psModule => psModule.reject(new Error('purs-loader failed'))) }) } } -- cgit v1.2.3