Skip to content

Commit 12d8d9f

Browse files
committed
add message to user for HeadlessException
To improve user-friendliness, headless exception now prints a message to the user with some solution options if they attempt to run the GUI on a headless machine
1 parent d84b123 commit 12d8d9f

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

src/main/java/scriptmanager/main/ScriptManager.java

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
import picocli.CommandLine;
44
import picocli.CommandLine.Command;
55

6+
import java.awt.HeadlessException;
67
import java.util.concurrent.Callable;
78

89
import scriptmanager.objects.ToolDescriptions;
10+
911
import scriptmanager.cli.BAM_Format_Converter.BAMtoBEDCLI;
1012
import scriptmanager.cli.BAM_Format_Converter.BAMtobedGraphCLI;
1113
import scriptmanager.cli.BAM_Format_Converter.BAMtoGFFCLI;
@@ -96,11 +98,28 @@
9698
public class ScriptManager implements Callable<Integer> {
9799

98100
@Override
99-
public Integer call(){
100-
System.out.println( "Use '-h' or '--help' for command-line usage guide" );
101-
ScriptManagerGUI gui = new ScriptManagerGUI();
102-
gui.launchApplication();
103-
return(0);
101+
public Integer call() {
102+
try {
103+
ScriptManagerGUI gui = new ScriptManagerGUI();
104+
System.out.println( "Use '-h' or '--help' for command-line usage guide" );
105+
gui.launchApplication();
106+
return(0);
107+
} catch (HeadlessException he) {
108+
he.printStackTrace();
109+
System.out.println("\n"
110+
+ "(ERROR!) Caught \"java.awt.HeadlessException\""
111+
+ "\n\n"
112+
+ "====What does this mean?====\n"
113+
+ "This usually means you attempted to access ScriptManager's GUI on a machine that does not have a graphical interface."
114+
+ "\n\n"
115+
+ "Please confirm you are working on a system that supports graphical interfaces and if it does not, you can...\n"
116+
+ " 1. set up X11 forwarding or\n"
117+
+ " 2. switch to using the command line interface (CLI):\n"
118+
+ " - https://pughlab.mbg.cornell.edu/scriptmanager-docs/docs/Guides/Getting-Started/command-line"
119+
+ "\n\n"
120+
);
121+
}
122+
return(1);
104123
}
105124

106125
public static void main(String[] args) {

0 commit comments

Comments
 (0)