ember-legacy-class-transform
Version:
The default blueprint for ember-cli addons.
53 lines (47 loc) • 1.75 kB
JavaScript
;
var path = require('path');
/*
* Subclass of `Error`.
*
* Includes detailed information about the errors from
* broccoli plugins, such as error type, code frames,
* broccoli node name and package versions.
*/
module.exports = BroccoliBuildError;
function BroccoliBuildError(originalError, node) {
var message = 'Build Canceled: Broccoli Builder ran into an error with ' + node.info.name + ' plugin. 💥\n' + originalError.message;
var error = Error.call(this, message);
this.message = error.message;
this.stack = originalError.stack;
var broccoliBuilderPackage = require(path.join(__dirname, '../package.json'));
/*
* Setting versions to `null` for now as it requires
* adding an option to broccoli-builder to identify
* ember cli/ember/ember data versions.
*/
this.broccoliPayload = {
versions: {
'broccoli-builder': broccoliBuilderPackage.version,
node: process.version
},
broccoliNode: {
nodeName: node.info.name,
nodeAnnotation: node.info.annotation,
instantiationStack: node.info.instantiationStack || ''
},
error: {
message: originalError.message,
stack: originalError.stack,
errorType: originalError.type || 'Build Error',
codeFrame: originalError.codeFrame || originalError.message,
location: originalError.location || {}
}
};
this.broccoliPayload.error.location.file = originalError.file;
this.broccoliPayload.error.location.treeDir = originalError.treeDir;
// we need to set this flag to make sure builder does re-throw
// and actually stops
this.wasCanceled = true;
}
BroccoliBuildError.prototype = Object.create(Error.prototype);
BroccoliBuildError.prototype.constructor = BroccoliBuildError;