better error handling
This commit is contained in:
parent
f2e7a8e455
commit
41ac2ec05e
|
@ -27,6 +27,9 @@ import board.TestLevel;
|
|||
import board.BoardObservers;
|
||||
|
||||
import designformats.specctra.DsnFile;
|
||||
import logger.FRLogger;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -365,6 +368,9 @@ public class BoardFrame extends javax.swing.JFrame
|
|||
*/
|
||||
public void set_context_sensitive_help(java.awt.Component p_component, String p_help_id)
|
||||
{
|
||||
if (p_component == null)
|
||||
throw new NullPointerException("p_component");
|
||||
|
||||
if (this.help_system_used)
|
||||
{
|
||||
java.awt.Component curr_component;
|
||||
|
@ -378,10 +384,11 @@ public class BoardFrame extends javax.swing.JFrame
|
|||
}
|
||||
String help_id = "html_files." + p_help_id;
|
||||
javax.help.CSH.setHelpIDString(curr_component, help_id);
|
||||
if (!this.is_web_start)
|
||||
{
|
||||
help_broker.enableHelpKey(curr_component, help_id, help_set);
|
||||
if (help_broker==null) {
|
||||
FRLogger.warning("help_broker is null");
|
||||
return;
|
||||
}
|
||||
help_broker.enableHelpKey(curr_component, help_id, help_set);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
|
||||
package gui;
|
||||
|
||||
import logger.FRLogger;
|
||||
|
||||
import javax.help.CSH;
|
||||
import javax.help.HelpSet;
|
||||
import javax.help.HelpSetException;
|
||||
|
@ -77,7 +79,7 @@ public class BoardMenuHelp extends BoardMenuHelpReduced
|
|||
URL hsURL = HelpSet.findHelpSet(this.getClass().getClassLoader(), helpset_name);
|
||||
if (hsURL == null)
|
||||
{
|
||||
System.out.println("HelpSet " + helpset_name + " not found.");
|
||||
FRLogger.warning("HelpSet " + helpset_name + " not found.");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
package gui;
|
||||
|
||||
import logger.FRLogger;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
import static javax.swing.JOptionPane.OK_OPTION;
|
||||
|
||||
/**
|
||||
* Andrey Belomutskiy
|
||||
* 6/28/2014
|
||||
*/
|
||||
public class DefaultExceptionHandler implements Thread.UncaughtExceptionHandler {
|
||||
public void uncaughtException(Thread t, Throwable e) {
|
||||
handleException(e);
|
||||
}
|
||||
|
||||
public static void handleException(Throwable e) {
|
||||
// Here you should have a more robust, permanent record of problems
|
||||
JOptionPane.showMessageDialog(findActiveFrame(), e.toString(), "Exception Occurred", OK_OPTION);
|
||||
FRLogger.error(e);
|
||||
}
|
||||
|
||||
private static Frame findActiveFrame() {
|
||||
Frame[] frames = JFrame.getFrames();
|
||||
for (Frame frame : frames) {
|
||||
if (frame.isVisible())
|
||||
return frame;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -36,6 +36,7 @@ public class MainApplication extends javax.swing.JFrame
|
|||
*/
|
||||
public static void main(String p_args[])
|
||||
{
|
||||
Thread.setDefaultUncaughtExceptionHandler(new DefaultExceptionHandler());
|
||||
StartupOptions startupOptions = StartupOptions.parse(p_args);
|
||||
|
||||
if (!(OFFLINE_ALLOWED || startupOptions.webstart_option))
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package logger;
|
||||
|
||||
/**
|
||||
* Andrey Belomutskiy
|
||||
* 6/28/2014
|
||||
*/
|
||||
public class FRLogger {
|
||||
public static void warning(String message) {
|
||||
/**
|
||||
* there is a problem that errors are currently being written to standard console and thus not visible to the
|
||||
* user
|
||||
*/
|
||||
System.out.println(message);
|
||||
}
|
||||
|
||||
public static void error(Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue