1: <?php
2:
3: namespace vierbergenlars\Forage\QueryParser;
4:
5: class ParseException extends \Exception
6: {
7: public function __construct($message, $string = null, $pos = null)
8: {
9: if($string) {
10: $startpos = $pos - 15;
11: $start_diff = 0;
12: if($startpos < 0) {
13: $start_diff = $startpos;
14: $startpos = 0;
15: }
16:
17: $str = substr($string, $startpos, 30);
18:
19: $err_pos_in_str = 15 + $start_diff;
20:
21:
22: $message.=' near ';
23: $msg_len = strlen($message);
24: $message.= $str;
25: $message.="\n";
26: $i = 0;
27: for($i = 0; $i < $msg_len; $i++)
28: $message.=' ';
29: for($i = 0; $i < $err_pos_in_str; $i++)
30: $message.='-';
31: $message.='^';
32: }
33: parent::__construct($message);
34: }
35:
36: }
37: