-
-
Notifications
You must be signed in to change notification settings - Fork 87
Refactoring SketchException
to be available outside of app
#1196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
catilac
merged 5 commits into
processing:main
from
joshgiesbrecht:SketchException-refactor-redo
Aug 28, 2025
+219
−327
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
22dde0f
refactoring SketchException to app:utils
joshgiesbrecht 88ac3bb
correcting build.gradle.kts files
joshgiesbrecht 266e7a5
correcting build.gradle.kts files
joshgiesbrecht 7512bc0
re-adding a processing.app.SketchException class that extends the new…
joshgiesbrecht 627eafb
tagging old location as deprecated
joshgiesbrecht File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,162 +1,30 @@ | ||
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ | ||
|
||
/* | ||
Part of the Processing project - http://processing.org | ||
Copyright (c) 2004-08 Ben Fry and Casey Reas | ||
Copyright (c) 2001-04 Massachusetts Institute of Technology | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software Foundation, | ||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
*/ | ||
// temporary band-aid class to support modes which are still looking here for the now-refactored class. | ||
// - josh giesbrecht | ||
|
||
package processing.app; | ||
|
||
@Deprecated | ||
// please migrate to using processing.utils.SketchException instead! all class functionality is the same as before. | ||
public class SketchException extends processing.utils.SketchException { | ||
|
||
/** | ||
* An exception with a line number attached that occurs | ||
* during either pre-processing, compile, or run time. | ||
*/ | ||
public class SketchException extends Exception { | ||
protected String message; | ||
protected int codeIndex; | ||
protected int codeLine; | ||
protected int codeColumn; | ||
protected boolean showStackTrace; | ||
|
||
|
||
public SketchException(String message) { | ||
this(message, true); | ||
} | ||
|
||
|
||
public SketchException(String message, boolean showStackTrace) { | ||
this(message, -1, -1, -1, showStackTrace); | ||
} | ||
|
||
|
||
public SketchException(String message, int file, int line) { | ||
this(message, file, line, -1, true); | ||
} | ||
|
||
|
||
public SketchException(String message, int file, int line, int column) { | ||
this(message, file, line, column, true); | ||
} | ||
|
||
|
||
public SketchException(String message, int file, int line, int column, | ||
boolean showStackTrace) { | ||
this.message = message; | ||
this.codeIndex = file; | ||
this.codeLine = line; | ||
this.codeColumn = column; | ||
this.showStackTrace = showStackTrace; | ||
} | ||
|
||
|
||
/** | ||
* Override getMessage() in Throwable, so that I can set | ||
* the message text outside the constructor. | ||
*/ | ||
public String getMessage() { | ||
return message; | ||
} | ||
|
||
|
||
public void setMessage(String message) { | ||
this.message = message; | ||
} | ||
|
||
|
||
public int getCodeIndex() { | ||
return codeIndex; | ||
} | ||
|
||
|
||
public void setCodeIndex(int index) { | ||
codeIndex = index; | ||
} | ||
|
||
|
||
public boolean hasCodeIndex() { | ||
return codeIndex != -1; | ||
} | ||
|
||
|
||
public int getCodeLine() { | ||
return codeLine; | ||
} | ||
|
||
|
||
public void setCodeLine(int line) { | ||
this.codeLine = line; | ||
} | ||
|
||
|
||
public boolean hasCodeLine() { | ||
return codeLine != -1; | ||
} | ||
|
||
|
||
public void setCodeColumn(int column) { | ||
this.codeColumn = column; | ||
} | ||
|
||
|
||
public int getCodeColumn() { | ||
return codeColumn; | ||
} | ||
|
||
|
||
public void showStackTrace() { | ||
showStackTrace = true; | ||
} | ||
|
||
|
||
public void hideStackTrace() { | ||
showStackTrace = false; | ||
} | ||
|
||
|
||
public boolean isStackTraceEnabled() { | ||
return showStackTrace; | ||
} | ||
// Idea complained without all these super wrappers for constructors. ¯\_(ツ)_/¯ sure, why not? | ||
public SketchException(String message) { | ||
super(message); | ||
} | ||
|
||
public SketchException(String message, boolean showStackTrace) { | ||
super(message, showStackTrace); | ||
} | ||
|
||
/** | ||
* Nix the java.lang crap out of an exception message | ||
* because it scares the children. | ||
* <P> | ||
* This function must be static to be used with super() | ||
* in each of the constructors above. | ||
*/ | ||
/* | ||
static public final String massage(String msg) { | ||
if (msg.indexOf("java.lang.") == 0) { | ||
//int dot = msg.lastIndexOf('.'); | ||
msg = msg.substring("java.lang.".length()); | ||
public SketchException(String message, int file, int line) { | ||
super(message, file, line); | ||
} | ||
return msg; | ||
//return (dot == -1) ? msg : msg.substring(dot+1); | ||
} | ||
*/ | ||
|
||
public SketchException(String message, int file, int line, int column) { | ||
super(message, file, line, column); | ||
} | ||
|
||
public void printStackTrace() { | ||
if (showStackTrace) { | ||
super.printStackTrace(); | ||
public SketchException(String message, int file, int line, int column, boolean showStackTrace) { | ||
super(message, file, line, column, showStackTrace); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
plugins { | ||
id("java") | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
testImplementation(platform("org.junit:junit-bom:5.10.0")) | ||
testImplementation("org.junit.jupiter:junit-jupiter") | ||
} | ||
|
||
tasks.test { | ||
useJUnitPlatform() | ||
} |
162 changes: 162 additions & 0 deletions
162
app/utils/src/main/java/processing/utils/SketchException.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ | ||
|
||
/* | ||
Part of the Processing project - http://processing.org | ||
|
||
Copyright (c) 2004-08 Ben Fry and Casey Reas | ||
Copyright (c) 2001-04 Massachusetts Institute of Technology | ||
|
||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2 of the License, or | ||
(at your option) any later version. | ||
|
||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
|
||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software Foundation, | ||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
*/ | ||
|
||
package processing.utils; | ||
|
||
|
||
/** | ||
* An exception with a line number attached that occurs | ||
* during either pre-processing, compile, or run time. | ||
*/ | ||
public class SketchException extends Exception { | ||
protected String message; | ||
protected int codeIndex; | ||
protected int codeLine; | ||
protected int codeColumn; | ||
protected boolean showStackTrace; | ||
|
||
|
||
public SketchException(String message) { | ||
this(message, true); | ||
} | ||
|
||
|
||
public SketchException(String message, boolean showStackTrace) { | ||
this(message, -1, -1, -1, showStackTrace); | ||
} | ||
|
||
|
||
public SketchException(String message, int file, int line) { | ||
this(message, file, line, -1, true); | ||
} | ||
|
||
|
||
public SketchException(String message, int file, int line, int column) { | ||
this(message, file, line, column, true); | ||
} | ||
|
||
|
||
public SketchException(String message, int file, int line, int column, | ||
boolean showStackTrace) { | ||
this.message = message; | ||
this.codeIndex = file; | ||
this.codeLine = line; | ||
this.codeColumn = column; | ||
this.showStackTrace = showStackTrace; | ||
} | ||
|
||
|
||
/** | ||
* Override getMessage() in Throwable, so that I can set | ||
* the message text outside the constructor. | ||
*/ | ||
public String getMessage() { | ||
return message; | ||
} | ||
|
||
|
||
public void setMessage(String message) { | ||
this.message = message; | ||
} | ||
|
||
|
||
public int getCodeIndex() { | ||
return codeIndex; | ||
} | ||
|
||
|
||
public void setCodeIndex(int index) { | ||
codeIndex = index; | ||
} | ||
|
||
|
||
public boolean hasCodeIndex() { | ||
return codeIndex != -1; | ||
} | ||
|
||
|
||
public int getCodeLine() { | ||
return codeLine; | ||
} | ||
|
||
|
||
public void setCodeLine(int line) { | ||
this.codeLine = line; | ||
} | ||
|
||
|
||
public boolean hasCodeLine() { | ||
return codeLine != -1; | ||
} | ||
|
||
|
||
public void setCodeColumn(int column) { | ||
this.codeColumn = column; | ||
} | ||
|
||
|
||
public int getCodeColumn() { | ||
return codeColumn; | ||
} | ||
|
||
|
||
public void showStackTrace() { | ||
showStackTrace = true; | ||
} | ||
|
||
|
||
public void hideStackTrace() { | ||
showStackTrace = false; | ||
} | ||
|
||
|
||
public boolean isStackTraceEnabled() { | ||
return showStackTrace; | ||
} | ||
|
||
|
||
/** | ||
* Nix the java.lang crap out of an exception message | ||
* because it scares the children. | ||
* <P> | ||
* This function must be static to be used with super() | ||
* in each of the constructors above. | ||
*/ | ||
/* | ||
static public final String massage(String msg) { | ||
if (msg.indexOf("java.lang.") == 0) { | ||
//int dot = msg.lastIndexOf('.'); | ||
msg = msg.substring("java.lang.".length()); | ||
} | ||
return msg; | ||
//return (dot == -1) ? msg : msg.substring(dot+1); | ||
} | ||
*/ | ||
|
||
|
||
public void printStackTrace() { | ||
if (showStackTrace) { | ||
super.printStackTrace(); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, when would this band-aid be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My plan was to submit PRs to the other supported modes to switch them over, once this is released. Then when all existing supported modes are fully switched over this could be deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considering we do not know which 3rd party modes/tools have used this class I would expect this stub to be there for quite a while.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joshgiesbrecht ah! also i just noticed you had already said this :) could you add a brief comment to the file documenting your plan?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@catilac @Stefterv There aren't that many modes to check, but I hadn't considered tools (or libraries, yikes). Is there a 'usual' for deprecated classes that should be planned for? I can update the file with specifics then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thing is, most modes we also do not have a way currently to easily publish new versions, so I suspect this stub to be there for quite a while