Files
coffeescript/lib/coffee-script/error.js
2013-02-25 14:41:34 -03:00

45 lines
1.7 KiB
JavaScript

// Generated by CoffeeScript 1.5.0
(function() {
var CompilerError, repeat,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
repeat = require('./helpers').repeat;
exports.CompilerError = CompilerError = (function(_super) {
__extends(CompilerError, _super);
CompilerError.prototype.name = 'CompilerError';
function CompilerError(message, startLine, startColumn, endLine, endColumn) {
this.message = message;
this.startLine = startLine;
this.startColumn = startColumn;
this.endLine = endLine != null ? endLine : this.startLine;
this.endColumn = endColumn != null ? endColumn : this.startColumn;
if (typeof Error.captureStackTrace === "function") {
Error.captureStackTrace(this, CompilerError);
}
}
CompilerError.prototype.prettyMessage = function(fileName, code) {
var errorLength, errorLine, marker, message;
message = "" + fileName + ":" + this.startLine + ":" + this.startColumn + ": " + this.message;
if (this.startLine === this.endLine) {
errorLine = code.split('\n')[this.startLine - 1];
errorLength = this.endColumn - this.startColumn + 1;
marker = (repeat(' ', this.startColumn - 1)) + (repeat('^', errorLength));
message += "\n" + errorLine + "\n" + marker;
} else {
void 0;
}
return message;
};
return CompilerError;
})(Error);
}).call(this);