Skip to content

Commit 22dde0f

Browse files
refactoring SketchException to app:utils
1 parent 3f36db5 commit 22dde0f

File tree

18 files changed

+200
-338
lines changed

18 files changed

+200
-338
lines changed

app/src/processing/app/Mode.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import processing.app.ui.Recent;
4141
import processing.app.ui.Toolkit;
4242
import processing.core.PApplet;
43+
import processing.utils.SketchException;
4344

4445

4546
public abstract class Mode {

app/src/processing/app/SketchException.java

Lines changed: 0 additions & 162 deletions
This file was deleted.

app/src/processing/app/ui/Editor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
import processing.app.RunnerListener;
6262
import processing.app.Sketch;
6363
import processing.app.SketchCode;
64-
import processing.app.SketchException;
64+
import processing.utils.SketchException;
6565
import processing.app.contrib.ContributionManager;
6666
import processing.app.laf.PdeMenuItemUI;
6767
import processing.app.syntax.*;

app/utils/build.gradle.kts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
plugins {
2+
id("java")
3+
}
4+
5+
group = "org.example"
6+
version = "unspecified"
7+
8+
repositories {
9+
mavenCentral()
10+
}
11+
12+
dependencies {
13+
testImplementation(platform("org.junit:junit-bom:5.10.0"))
14+
testImplementation("org.junit.jupiter:junit-jupiter")
15+
}
16+
17+
tasks.test {
18+
useJUnitPlatform()
19+
}
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
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.utils;
25+
26+
27+
/**
28+
* An exception with a line number attached that occurs
29+
* during either pre-processing, compile, or run time.
30+
*/
31+
public class SketchException extends Exception {
32+
protected String message;
33+
protected int codeIndex;
34+
protected int codeLine;
35+
protected int codeColumn;
36+
protected boolean showStackTrace;
37+
38+
39+
public SketchException(String message) {
40+
this(message, true);
41+
}
42+
43+
44+
public SketchException(String message, boolean showStackTrace) {
45+
this(message, -1, -1, -1, showStackTrace);
46+
}
47+
48+
49+
public SketchException(String message, int file, int line) {
50+
this(message, file, line, -1, true);
51+
}
52+
53+
54+
public SketchException(String message, int file, int line, int column) {
55+
this(message, file, line, column, true);
56+
}
57+
58+
59+
public SketchException(String message, int file, int line, int column,
60+
boolean showStackTrace) {
61+
this.message = message;
62+
this.codeIndex = file;
63+
this.codeLine = line;
64+
this.codeColumn = column;
65+
this.showStackTrace = showStackTrace;
66+
}
67+
68+
69+
/**
70+
* Override getMessage() in Throwable, so that I can set
71+
* the message text outside the constructor.
72+
*/
73+
public String getMessage() {
74+
return message;
75+
}
76+
77+
78+
public void setMessage(String message) {
79+
this.message = message;
80+
}
81+
82+
83+
public int getCodeIndex() {
84+
return codeIndex;
85+
}
86+
87+
88+
public void setCodeIndex(int index) {
89+
codeIndex = index;
90+
}
91+
92+
93+
public boolean hasCodeIndex() {
94+
return codeIndex != -1;
95+
}
96+
97+
98+
public int getCodeLine() {
99+
return codeLine;
100+
}
101+
102+
103+
public void setCodeLine(int line) {
104+
this.codeLine = line;
105+
}
106+
107+
108+
public boolean hasCodeLine() {
109+
return codeLine != -1;
110+
}
111+
112+
113+
public void setCodeColumn(int column) {
114+
this.codeColumn = column;
115+
}
116+
117+
118+
public int getCodeColumn() {
119+
return codeColumn;
120+
}
121+
122+
123+
public void showStackTrace() {
124+
showStackTrace = true;
125+
}
126+
127+
128+
public void hideStackTrace() {
129+
showStackTrace = false;
130+
}
131+
132+
133+
public boolean isStackTraceEnabled() {
134+
return showStackTrace;
135+
}
136+
137+
138+
/**
139+
* Nix the java.lang crap out of an exception message
140+
* because it scares the children.
141+
* <P>
142+
* This function must be static to be used with super()
143+
* in each of the constructors above.
144+
*/
145+
/*
146+
static public final String massage(String msg) {
147+
if (msg.indexOf("java.lang.") == 0) {
148+
//int dot = msg.lastIndexOf('.');
149+
msg = msg.substring("java.lang.".length());
150+
}
151+
return msg;
152+
//return (dot == -1) ? msg : msg.substring(dot+1);
153+
}
154+
*/
155+
156+
157+
public void printStackTrace() {
158+
if (showStackTrace) {
159+
super.printStackTrace();
160+
}
161+
}
162+
}

java/src/processing/mode/java/Commander.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import processing.app.Preferences;
3434
import processing.app.RunnerListener;
3535
import processing.app.Sketch;
36-
import processing.mode.java.preproc.SketchException;
36+
import processing.utils.SketchException;
3737
import processing.app.Util;
3838
import processing.app.contrib.ModeContribution;
3939
import processing.core.PApplet;

java/src/processing/mode/java/Compiler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import processing.app.*;
2727
import processing.app.ui.Editor;
2828
import processing.core.*;
29-
import processing.mode.java.preproc.SketchException;
29+
import processing.utils.SketchException;
3030

3131
import java.io.*;
3232
import java.lang.reflect.Method;

0 commit comments

Comments
 (0)