Sha256: f66f615bb54870c3e6b3920acd1b8df52355b39eaa5a48821c560bea4310dcf8

Contents?: true

Size: 801 Bytes

Versions: 26

Compression:

Stored size: 801 Bytes

Contents

"use strict";

const STRIP_FILENAME_RE = /^[^:]+: /;

const format = err => {
  if (err instanceof SyntaxError) {
    err.name = "SyntaxError";
    err.message = err.message.replace(STRIP_FILENAME_RE, "");
    err.hideStack = true;
  } else if (err instanceof TypeError) {
    err.name = null;
    err.message = err.message.replace(STRIP_FILENAME_RE, "");
    err.hideStack = true;
  }

  return err;
};

class LoaderError extends Error {
  constructor(err) {
    super();
    const {
      name,
      message,
      codeFrame,
      hideStack
    } = format(err);
    this.name = "BabelLoaderError";
    this.message = `${name ? `${name}: ` : ""}${message}\n\n${codeFrame}\n`;
    this.hideStack = hideStack;
    Error.captureStackTrace(this, this.constructor);
  }

}

module.exports = LoaderError;

Version data entries

26 entries across 25 versions & 8 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/babel-loader/lib/Error.js
disco_app-0.18.0 test/dummy/node_modules/babel-loader/lib/Error.js
disco_app-0.18.2 test/dummy/node_modules/babel-loader/lib/Error.js
disco_app-0.16.1 test/dummy/node_modules/babel-loader/lib/Error.js
disco_app-0.15.2 test/dummy/node_modules/babel-loader/lib/Error.js
disco_app-0.18.4 test/dummy/node_modules/babel-loader/lib/Error.js
disco_app-0.18.1 test/dummy/node_modules/babel-loader/lib/Error.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/babel-loader/lib/Error.js
disco_app-0.14.0 test/dummy/node_modules/babel-loader/lib/Error.js
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/babel-loader/lib/Error.js
tang-0.2.1 spec/tang_app/node_modules/babel-loader/lib/Error.js
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/babel-loader/lib/Error.js
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/babel-loader/lib/Error.js
ruby2js-4.0.4 lib/tasks/testrails/node_modules/babel-loader/lib/Error.js
ruby2js-4.0.3 lib/tasks/testrails/node_modules/babel-loader/lib/Error.js
tang-0.2.0 spec/tang_app/node_modules/babel-loader/lib/Error.js
tang-0.1.0 spec/tang_app/node_modules/babel-loader/lib/Error.js
tang-0.0.9 spec/tang_app/node_modules/babel-loader/lib/Error.js
enju_library-0.3.8 spec/dummy/node_modules/babel-loader/lib/Error.js
jester-data-8.0.0 node_modules/babel-loader/lib/Error.js