diff options
author | eric thul <thul.eric@gmail.com> | 2016-11-05 14:01:18 -0400 |
---|---|---|
committer | eric thul <thul.eric@gmail.com> | 2016-11-05 14:01:18 -0400 |
commit | 4b99e432d63e7a0ce8ad8d2184232417853bfd2b (patch) | |
tree | 8b0cf5796e152f2b76753de40576ca193933f004 | |
parent | 2cca7e91062917d3239f179770133175350af7cc (diff) | |
download | purs-loader-4b99e432d63e7a0ce8ad8d2184232417853bfd2b.tar.gz purs-loader-4b99e432d63e7a0ce8ad8d2184232417853bfd2b.tar.zst purs-loader-4b99e432d63e7a0ce8ad8d2184232417853bfd2b.zip |
Wrapping reject values in Error objects
-rw-r--r-- | src/Psc.js | 4 | ||||
-rw-r--r-- | src/PscIde.js | 12 | ||||
-rw-r--r-- | src/index.js | 2 |
3 files changed, 9 insertions, 9 deletions
@@ -41,7 +41,7 @@ function compile(psModule) { | |||
41 | cache.compilationFinished = true | 41 | cache.compilationFinished = true |
42 | if (code !== 0) { | 42 | if (code !== 0) { |
43 | cache.errors = stderr.join('') | 43 | cache.errors = stderr.join('') |
44 | reject(true) | 44 | reject(new Error('compilation failed')) |
45 | } else { | 45 | } else { |
46 | cache.warnings = stderr.join('') | 46 | cache.warnings = stderr.join('') |
47 | resolve(psModule) | 47 | resolve(psModule) |
@@ -83,7 +83,7 @@ function bundle(options, cache) { | |||
83 | compilation.on('close', code => { | 83 | compilation.on('close', code => { |
84 | if (code !== 0) { | 84 | if (code !== 0) { |
85 | cache.errors = (cache.errors || '') + stderr.join('') | 85 | cache.errors = (cache.errors || '') + stderr.join('') |
86 | return reject(true) | 86 | return reject(new Error('bundling failed')) |
87 | } | 87 | } |
88 | cache.bundle = stderr | 88 | cache.bundle = stderr |
89 | resolve(fs.appendFileAsync(options.bundleOutput, `module.exports = ${options.bundleNamespace}`)) | 89 | 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) { | |||
38 | ideClient.stderr.on('data', data => { | 38 | ideClient.stderr.on('data', data => { |
39 | debug(data.toString()) | 39 | debug(data.toString()) |
40 | cache.ideServer = false | 40 | cache.ideServer = false |
41 | reject(true) | 41 | reject(new Error('psc-ide-client failed')) |
42 | }) | 42 | }) |
43 | ideClient.stdout.once('data', data => { | 43 | ideClient.stdout.once('data', data => { |
44 | debug(data.toString()) | 44 | debug(data.toString()) |
@@ -49,11 +49,11 @@ function connect(psModule) { | |||
49 | resolve(psModule) | 49 | resolve(psModule) |
50 | } else { | 50 | } else { |
51 | cache.ideServer = ideServer | 51 | cache.ideServer = ideServer |
52 | reject(true) | 52 | reject(new Error('psc-ide-client failed')) |
53 | } | 53 | } |
54 | } else { | 54 | } else { |
55 | cache.ideServer = false | 55 | cache.ideServer = false |
56 | reject(true) | 56 | reject(new Error('psc-ide-client failed')) |
57 | } | 57 | } |
58 | }) | 58 | }) |
59 | ideClient.stdin.resume() | 59 | ideClient.stdin.resume() |
@@ -135,7 +135,7 @@ function rebuild(psModule) { | |||
135 | if (res && !Array.isArray(res.result)) { | 135 | if (res && !Array.isArray(res.result)) { |
136 | return res.resultType === 'success' | 136 | return res.resultType === 'success' |
137 | ? resolve(psModule) | 137 | ? resolve(psModule) |
138 | : reject('psc-ide rebuild failed') | 138 | : reject(new Error('psc-ide rebuild failed')) |
139 | } | 139 | } |
140 | 140 | ||
141 | Promise.map(res.result, (item, i) => { | 141 | Promise.map(res.result, (item, i) => { |
@@ -153,10 +153,10 @@ function rebuild(psModule) { | |||
153 | })) | 153 | })) |
154 | .then(() => request({ command: 'load' })) | 154 | .then(() => request({ command: 'load' })) |
155 | .then(resolve) | 155 | .then(resolve) |
156 | .catch(() => reject('psc-ide rebuild failed')) | 156 | .catch(() => reject(new Error('psc-ide rebuild failed'))) |
157 | } | 157 | } |
158 | cache.errors = compileMessages.join('\n') | 158 | cache.errors = compileMessages.join('\n') |
159 | reject('psc-ide rebuild failed') | 159 | reject(new Error('psc-ide rebuild failed')) |
160 | } else { | 160 | } else { |
161 | cache.warnings = compileMessages.join('\n') | 161 | cache.warnings = compileMessages.join('\n') |
162 | resolve(psModule) | 162 | 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) { | |||
125 | })) | 125 | })) |
126 | .catch(error => { | 126 | .catch(error => { |
127 | cache.deferred[0].reject(error) | 127 | cache.deferred[0].reject(error) |
128 | cache.deferred.slice(1).forEach(psModule => psModule.reject(true)) | 128 | cache.deferred.slice(1).forEach(psModule => psModule.reject(new Error('purs-loader failed'))) |
129 | }) | 129 | }) |
130 | } | 130 | } |
131 | } | 131 | } |