Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
226 | daniel-mar | 1 | <?php |
2 | |||
3 | class VolcanoException extends Exception { |
||
4 | |||
5 | function __construct($message, $metadata=array()) { |
||
6 | $msg = $message; |
||
7 | if (isset($metadata['oid'])) $msg .= " for OID ".$metadata['oid']; |
||
8 | if (isset($metadata['macro'])) $msg .= " for Macro ".$metadata['macro']; |
||
9 | if (isset($metadata['source'])) $msg .= " at ".$this->showSource($metadata['source']); |
||
10 | |||
11 | parent::__construct($msg); |
||
12 | } |
||
13 | |||
14 | protected static function showSource($source) { |
||
15 | if (strpos($source, ':') === false) return $source; |
||
16 | preg_match('@^(.+):(\\d+)$@', $source, $m); |
||
17 | $file = $m[1]; |
||
18 | $line = $m[2]; |
||
19 | return "$file at line $line"; |
||
20 | } |
||
21 | } |