01 /*
02 * SearchException.java
03 *
04 * Copyright (c) 1995-2010, The University of Sheffield. See the file
05 * COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
06 *
07 * This file is part of GATE (see http://gate.ac.uk/), and is free
08 * software, licenced under the GNU Library General Public License,
09 * Version 2, June 1991 (in the distribution as file licence.html,
10 * and also available at http://gate.ac.uk/gate/licence.html).
11 *
12 * Rosen Marinov, 19/Apr/2002
13 *
14 */
15
16 package gate.creole.ir;
17
18 public class SearchException extends Exception{
19
20 public SearchException(String msg){
21 super(msg);
22 }
23
24 public SearchException(String errorType, String error,
25 String erroneousLine) {
26
27 super("\nError: "+errorType+" - "+error+".\n"
28 +erroneousLine);
29 }
30
31 public SearchException(String errorType, String error,
32 String erroneousLine, int errorPosition) {
33
34 super("\nError: "+errorType+" - "+error+".\n"
35 +erroneousLine+"\n"
36 +caretLine(errorPosition));
37 }
38
39 final static private String caretLine(int errorPosition) {
40 StringBuffer s = new StringBuffer();
41 for (int c = 0; c < errorPosition; c++) {
42 s.append(" ");
43 }
44 s.append("^");
45 return s.toString();
46 }
47
48 }
|