aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorCyril Sobierajewicz <cyril.sobierajewicz@fretlink.com>2018-12-03 11:53:45 +0100
committerCyril Sobierajewicz <cyril.sobierajewicz@fretlink.com>2018-12-03 11:57:30 +0100
commite3de0f7156c579e5db05e6cb895df3884e8b9cdd (patch)
tree02e3769ef013b434332c0da1be9f78bf2e448daf
parent1142175778cdc21add2d4b494a02c53050856aa5 (diff)
downloadpurs-loader-e3de0f7156c579e5db05e6cb895df3884e8b9cdd.tar.gz
purs-loader-e3de0f7156c579e5db05e6cb895df3884e8b9cdd.tar.zst
purs-loader-e3de0f7156c579e5db05e6cb895df3884e8b9cdd.zip
Tag errors with a specific constructor to simplify their detection
-rw-r--r--src/index.js2
-rw-r--r--src/utils.js11
2 files changed, 12 insertions, 1 deletions
diff --git a/src/index.js b/src/index.js
index 01ad5a6..8a2e468 100644
--- a/src/index.js
+++ b/src/index.js
@@ -238,7 +238,7 @@ module.exports = function purescriptLoader(source, map) {
238 modules.push(desc); 238 modules.push(desc);
239 } 239 }
240 240
241 CACHE_VAR.errors.push(Object.assign(new Error(pscMessage), { modules })); 241 CACHE_VAR.errors.push(new utils.PscError(pscMessage, modules));
242 } 242 }
243 } 243 }
244 } 244 }
diff --git a/src/utils.js b/src/utils.js
index 0ab00eb..671b580 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -1,5 +1,16 @@
1const path = require('path'); 1const path = require('path');
2 2
3exports.PscError = class PscError extends Error {
4 constructor(message, modules) {
5 super(message);
6 this.modules = modules;
7 }
8
9 static get name() {
10 return 'PscError';
11 }
12};
13
3const repeat = (value, times) => 14const repeat = (value, times) =>
4 times <= 0 ? [] : [value, ...repeat(value, times - 1)]; 15 times <= 0 ? [] : [value, ...repeat(value, times - 1)];
5const diffPursModuleNames = (from, target, parts) => { 16const diffPursModuleNames = (from, target, parts) => {