Debian Codegraph @

arduino-core/src/processing/app/debug/RunnerException.java

raw symbols SCIP
1 /* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
3 /*
4 Part of the Processing project - http://processing.org
5
6 Copyright (c) 2004-08 Ben Fry and Casey Reas
7 Copyright (c) 2001-04 Massachusetts Institute of Technology
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software Foundation,
21 Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23
24 package processing.app.debug;
25
26 import processing.app.SketchFile;
27
28 /**
29 * An exception with a line number attached that occurs
30 * during either compile time or run time.
31 */
32 @SuppressWarnings("serial")
33 public class RunnerException extends Exception {
34 protected String message;
35 protected SketchFile codeFile;
36 protected int codeLine;
37 protected int codeColumn;
38 protected boolean showStackTrace;
39
40
41 public RunnerException(String message) {
42 this(message, true);
43 }
44
45 public RunnerException(String message, boolean showStackTrace) {
46 this(message, null, -1, -1, showStackTrace);
47 }
48
49 public RunnerException(String message, SketchFile file, int line) {
50 this(message, file, line, -1, true);
51 }
52
53
54 public RunnerException(String message, SketchFile file, int line, int column) {
55 this(message, file, line, column, true);
56 }
57
58
59 public RunnerException(String message, SketchFile file, int line, int column,
60 boolean showStackTrace) {
61 this.message = message;
62 this.codeFile = file;
63 this.codeLine = line;
64 this.codeColumn = column;
65 this.showStackTrace = showStackTrace;
66 }
67
68
69 public RunnerException(Exception e) {
70 super(e);
71 this.showStackTrace = true;
72 }
73
74 /**
75 * Override getMessage() in Throwable, so that I can set
76 * the message text outside the constructor.
77 */
78 @Override
79 public String getMessage() {
80 return message;
81 }
82
83
84 public void setMessage(String message) {
85 this.message = message;
86 }
87
88
89 public SketchFile getCodeFile() {
90 return codeFile;
91 }
92
93
94 public void setCodeFile(SketchFile file) {
95 codeFile = file;
96 }
97
98 public boolean hasCodeFile() {
99 return codeFile != null;
100 }
101
102
103 public int getCodeLine() {
104 return codeLine;
105 }
106
107
108 public void setCodeLine(int line) {
109 this.codeLine = line;
110 }
111
112 public boolean hasCodeLine() {
113 return codeLine != -1;
114 }
115
116
117 public void setCodeColumn(int column) {
118 this.codeColumn = column;
119 }
120
121 public int getCodeColumn() {
122 return codeColumn;
123 }
124
125
126 public void showStackTrace() {
127 showStackTrace = true;
128 }
129
130
131 public void hideStackTrace() {
132 showStackTrace = false;
133 }
134
135
136 /**
137 * Nix the java.lang crap out of an exception message
138 * because it scares the children.
139 * <P>
140 * This function must be static to be used with super()
141 * in each of the constructors above.
142 */
143 /*
144 static public final String massage(String msg) {
145 if (msg.indexOf("java.lang.") == 0) {
146 //int dot = msg.lastIndexOf('.');
147 msg = msg.substring("java.lang.".length());
148 }
149 return msg;
150 //return (dot == -1) ? msg : msg.substring(dot+1);
151 }
152 */
153
154
155 @Override
156 public void printStackTrace() {
157 if (showStackTrace) {
158 super.printStackTrace();
159 }
160 }
161 }