summaryrefslogtreecommitdiff
path: root/ParseCompileError.php
diff options
context:
space:
mode:
authorKevin Chabowski <kevin@kch42.de>2014-05-18 00:25:49 +0200
committerKevin Chabowski <kevin@kch42.de>2014-05-18 00:25:49 +0200
commitfad93506cd56b976d1413ed5adef87701df715bd (patch)
treedd4f0fca57633dcfeb66622b4c20497090bfff16 /ParseCompileError.php
parenta77a2ec58947f5fc7cb4023db3b8f8298e2f01f2 (diff)
downloadste-fad93506cd56b976d1413ed5adef87701df715bd.tar.gz
ste-fad93506cd56b976d1413ed5adef87701df715bd.tar.bz2
ste-fad93506cd56b976d1413ed5adef87701df715bd.zip
One file per class and new namespace.
We should be able to use a PSR4 autoloader (like composer's) now. ste.php is still there as a fallback for old applications.
Diffstat (limited to 'ParseCompileError.php')
-rw-r--r--ParseCompileError.php22
1 files changed, 22 insertions, 0 deletions
diff --git a/ParseCompileError.php b/ParseCompileError.php
new file mode 100644
index 0000000..5ee37c7
--- /dev/null
+++ b/ParseCompileError.php
@@ -0,0 +1,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;
+ }
+}