summaryrefslogtreecommitdiff
path: root/src/ste/ParseCompileError.php
blob: 8a7c36bcf8563c827c37be66d393a67dab418529 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php

namespace kch42\ste;

class ParseCompileError extends \Exception {
	public $msg;
	public $tpl;
	public $off;

	public function __construct($msg, $tpl, $offset, $code = 0, $previous = NULL) {
		$this->msg = $msg;
		$this->tpl = $tpl;
		$this->off = $offset;
		$this->message = "$msg (Template $tpl, Offset $offset)";
	}

	public function rewrite($code) {
		$line = substr_count(str_replace("\r\n", "\n", substr($code, 0, $this->off)), "\n") + 1;
		$this->message = "{$this->msg} (Template {$this->tpl}, Line $line)";
		$this->is_rewritten = true;
	}
}