1: <?php
2:
3: 4: 5: 6:
7:
8: namespace Latte;
9:
10:
11: 12: 13:
14: class CompileException extends \Exception
15: {
16:
17: public $sourceCode;
18:
19:
20: public $sourceName;
21:
22:
23: public $sourceLine;
24:
25:
26: public function setSource($code, $line, $name = null)
27: {
28: $this->sourceCode = (string) $code;
29: $this->sourceLine = (int) $line;
30: $this->sourceName = (string) $name;
31: if (@is_file($name)) {
32: $this->message = rtrim($this->message, '.')
33: . ' in ' . str_replace(dirname(dirname($name)), '...', $name) . ($line ? ":$line" : '');
34: }
35: return $this;
36: }
37: }
38:
39:
40: 41: 42:
43: class RegexpException extends \Exception
44: {
45: public static $messages = [
46: PREG_INTERNAL_ERROR => 'Internal error',
47: PREG_BACKTRACK_LIMIT_ERROR => 'Backtrack limit was exhausted',
48: PREG_RECURSION_LIMIT_ERROR => 'Recursion limit was exhausted',
49: PREG_BAD_UTF8_ERROR => 'Malformed UTF-8 data',
50: 5 => 'Offset didn\'t correspond to the begin of a valid UTF-8 code point',
51: 6 => 'Failed due to limited JIT stack space',
52: ];
53:
54:
55: public function __construct($message, $code = null)
56: {
57: parent::__construct($message ?: (isset(self::$messages[$code]) ? self::$messages[$code] : 'Unknown error'), $code);
58: }
59: }
60:
61:
62: 63: 64:
65: class RuntimeException extends \Exception
66: {
67: }
68: