Sha256: 118ba2d86e5158ae1a7e2ca0afc48a8840e6bca5aaf7c8a0e42716ba309bbac2

Contents?: true

Size: 658 Bytes

Versions: 4

Compression:

Stored size: 658 Bytes

Contents

import locate from './locate.js';
import getSnippet from './getSnippet.js';

export default class CompileError extends Error {
	constructor(message, node) {
		super(message);

		this.name = 'CompileError';
		if (!node) {
			return;
		}

		const source = node.program.magicString.original;
		const loc = locate(source, node.start);

		this.message = message + ` (${loc.line}:${loc.column})`;

		this.stack = new Error().stack.replace(
			new RegExp(`.+new ${this.name}.+\\n`, 'm'),
			''
		);

		this.loc = loc;
		this.snippet = getSnippet(source, loc, node.end - node.start);
	}

	toString() {
		return `${this.name}: ${this.message}\n${this.snippet}`;
	}
}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jass-0.9.5 vendor/node_modules/buble/src/utils/CompileError.js
jass-0.9.4 vendor/node_modules/buble/src/utils/CompileError.js
jass-0.9.3 vendor/node_modules/buble/src/utils/CompileError.js
jass-0.9.1 vendor/node_modules/buble/src/utils/CompileError.js