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:
44: class RegexpException extends \Exception
45: {
46: public static $messages = array(
47: PREG_INTERNAL_ERROR => 'Internal error',
48: PREG_BACKTRACK_LIMIT_ERROR => 'Backtrack limit was exhausted',
49: PREG_RECURSION_LIMIT_ERROR => 'Recursion limit was exhausted',
50: PREG_BAD_UTF8_ERROR => 'Malformed UTF-8 data',
51: 5 => 'Offset didn\'t correspond to the begin of a valid UTF-8 code point',
52: );
53:
54: public function __construct($message, $code = NULL)
55: {
56: parent::__construct($message ?: (isset(self::$messages[$code]) ? self::$messages[$code] : 'Unknown error'), $code);
57: }
58:
59: }
60:
61:
62: 63: 64:
65: class RuntimeException extends \Exception
66: {
67: }
68: