From e3de0f7156c579e5db05e6cb895df3884e8b9cdd Mon Sep 17 00:00:00 2001 From: Cyril Sobierajewicz Date: Mon, 3 Dec 2018 11:53:45 +0100 Subject: Tag errors with a specific constructor to simplify their detection --- src/index.js | 2 +- src/utils.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'src') 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) { modules.push(desc); } - CACHE_VAR.errors.push(Object.assign(new Error(pscMessage), { modules })); + CACHE_VAR.errors.push(new utils.PscError(pscMessage, modules)); } } } 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 @@ const path = require('path'); +exports.PscError = class PscError extends Error { + constructor(message, modules) { + super(message); + this.modules = modules; + } + + static get name() { + return 'PscError'; + } +}; + const repeat = (value, times) => times <= 0 ? [] : [value, ...repeat(value, times - 1)]; const diffPursModuleNames = (from, target, parts) => { -- cgit v1.2.3