Skip to content

Commit

Permalink
Return error
Browse files Browse the repository at this point in the history
  • Loading branch information
oeway committed Apr 9, 2024
1 parent 6c1f05d commit 4ef7a68
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-imagej.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
if: github.ref == 'refs/heads/master'
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: 1.53m2
tag: 1.53m3
name: ImageJ.JS
files: imagej-js-dist/
allow_override: true
12 changes: 10 additions & 2 deletions src/main/java/ij/IJ.java
Original file line number Diff line number Diff line change
Expand Up @@ -919,8 +919,16 @@ public static void error(String title, String msg) {
IJ.log(title2 + ": " + msg);
if (abortMacro && (title.contains("Open")||title.contains("Reader")))
abortMacro = false;
} else
showMessage(title2, msg);
} else {
try{
// e.printStackTrace();
Global.jsCall("onMacroReject", msg);
}
catch(Exception e){
showMessage(title2, msg);
}
}

redirectErrorMessages = false;
if (abortMacro)
Macro.abort();
Expand Down
42 changes: 28 additions & 14 deletions src/main/java/ij/macro/Interpreter.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.*;
import java.awt.event.KeyEvent;
import java.io.PrintWriter;
import com.leaningtech.client.Global;


/** This is the recursive descent parser/interpreter for the ImageJ macro language. */
Expand Down Expand Up @@ -1413,20 +1414,33 @@ void showError(String title, String msg, String[] variables) {
if (noImages)
title = "No Image";
Macro.setOptions(null);
GenericDialog gd = new GenericDialog(title);
gd.setInsets(6,5,0);
gd.addMessage(msg);
gd.setInsets(15,30,5);
if (!noImages)
gd.addCheckbox("Show \"Debug\" Window", showVariables);
gd.hideCancelButton();
gd.showDialog();
if (!noImages)
showVariables = gd.getNextBoolean();
else
showVariables = false;
if (!gd.wasCanceled() && showVariables)
updateDebugWindow(variables, null);

try{
// e.printStackTrace();
String[] markedVariables = markChanges(variables);
// concatenate variables
String variablesString = "";
for (int i = 0; i < markedVariables.length; i++) {
variablesString += markedVariables[i] + "\n";
}
Global.jsCall("onMacroReject", "" + title + ": " + msg + "\n" + variablesString);
}
catch(Exception e){
GenericDialog gd = new GenericDialog(title);
gd.setInsets(6,5,0);
gd.addMessage(msg);
gd.setInsets(15,30,5);
if (!noImages)
gd.addCheckbox("Show \"Debug\" Window", showVariables);
gd.hideCancelButton();
gd.showDialog();
if (!noImages)
showVariables = gd.getNextBoolean();
else
showVariables = false;
if (!gd.wasCanceled() && showVariables)
updateDebugWindow(variables, null);
}
}

public TextWindow updateDebugWindow(String[] variables, TextWindow debugWindow) {
Expand Down

0 comments on commit 4ef7a68

Please sign in to comment.