function buildError(err, code, filename = 'unknown') {
	const { loc, message } = err;
	if (!loc) return { message };
	const text = message.replace(/ \(\d+:\d+\)$/, '');
	const position = `${filename}:${loc.line}:${loc.column + 1}`;
	return {
		loc,
		message: `${text} (${position})`,
		codeFrame: codeFrame(code, loc)
	};
}
@param {Error & { loc?: { line: number, column: number }}} err
@param {string} code
@param {string} [filename]
@returns {{ loc?: number | {line: number, column: number}, message: string, codeFrame?: string }}