summaryrefslogtreecommitdiff
path: root/ParseCompileError.php
blob: 5ee37c7d35c76b8022275cd4ea8a74776d7f4734 (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;
	}
}