1 | <?php |
||
19 | class ParseException extends RuntimeException |
||
20 | { |
||
21 | private $parsedFile; |
||
22 | private $parsedLine; |
||
23 | private $snippet; |
||
24 | private $rawMessage; |
||
25 | |||
26 | /** |
||
27 | * Constructor. |
||
28 | * |
||
29 | * @param string $message The error message |
||
30 | * @param int $parsedLine The line where the error occurred |
||
31 | * @param int $snippet The snippet of code near the problem |
||
32 | * @param string $parsedFile The file name where the error occurred |
||
33 | * @param \Exception $previous The previous exception |
||
34 | */ |
||
35 | public function __construct($message, $parsedLine = -1, $snippet = null, $parsedFile = null, \Exception $previous = null) |
||
36 | { |
||
37 | $this->parsedFile = $parsedFile; |
||
38 | $this->parsedLine = $parsedLine; |
||
39 | $this->snippet = $snippet; |
||
40 | $this->rawMessage = $message; |
||
41 | |||
42 | $this->updateRepr(); |
||
43 | |||
44 | parent::__construct($this->message, 0, $previous); |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * Gets the snippet of code near the error. |
||
49 | * |
||
50 | * @return string The snippet of code |
||
51 | */ |
||
52 | public function getSnippet() |
||
56 | |||
57 | /** |
||
58 | * Sets the snippet of code near the error. |
||
59 | * |
||
60 | * @param string $snippet The code snippet |
||
61 | */ |
||
62 | public function setSnippet($snippet) |
||
63 | { |
||
64 | $this->snippet = $snippet; |
||
65 | |||
66 | $this->updateRepr(); |
||
67 | } |
||
68 | |||
69 | /** |
||
70 | * Gets the filename where the error occurred. |
||
71 | * |
||
72 | * This method returns null if a string is parsed. |
||
73 | * |
||
74 | * @return string The filename |
||
75 | */ |
||
76 | public function getParsedFile() |
||
80 | |||
81 | /** |
||
82 | * Sets the filename where the error occurred. |
||
83 | * |
||
84 | * @param string $parsedFile The filename |
||
85 | */ |
||
86 | public function setParsedFile($parsedFile) |
||
87 | { |
||
88 | $this->parsedFile = $parsedFile; |
||
89 | |||
90 | $this->updateRepr(); |
||
91 | } |
||
92 | |||
93 | /** |
||
94 | * Gets the line where the error occurred. |
||
95 | * |
||
96 | * @return int The file line |
||
97 | */ |
||
98 | public function getParsedLine() |
||
102 | |||
103 | /** |
||
104 | * Sets the line where the error occurred. |
||
105 | * |
||
106 | * @param int $parsedLine The file line |
||
107 | */ |
||
108 | public function setParsedLine($parsedLine) |
||
114 | |||
115 | private function updateRepr() |
||
141 | } |
||
142 |