net.sf.colossus.util
Class ErrorUtils

java.lang.Object
  extended by net.sf.colossus.util.ErrorUtils

public class ErrorUtils
extends java.lang.Object

Small helper methods to deal with Exceptions, how to get them into String-format and display them to the user etc.

Displaying of the message dialog is also provided here, so that otherwise non-GUI classes have a simple way to show a dialog, without need to worry about being headless etc.


Field Summary
private static java.util.List<java.lang.String> errorDuringFunctionalTest
           
private static java.util.logging.Logger LOGGER
           
 
Constructor Summary
ErrorUtils()
           
 
Method Summary
static boolean checkErrorDuringFunctionalTest()
           
static void clearErrorDuringFunctionalTest()
           
static boolean copyToClipboard(java.lang.String message)
           
private static void exitIfStresstest()
          During stress-testing, don't bother to show message, instead exit immediately:
static java.lang.String getErrorDuringFunctionalTest()
           
private static javax.swing.JFrame makeDummyErrorFrame(java.lang.String frameTitle)
          Creates a JFrame object which can be used as parent for a dialog; the frame is centered and contains a text telling that it is a dummy frame just for that purpose that one does not miss the message dialog.
static java.lang.String makeStackTraceString(java.lang.Throwable e)
          Query the stacktrace items from an exception, and put them nicely into a single string.
static void setErrorDuringFunctionalTest(java.lang.String reason)
           
static void showErrorDialog(javax.swing.JFrame frame, java.lang.String title, java.lang.String message)
          Show display an error/warning in an JOptionPage message dialog, but this one here typically NOT for the situation that an exception had occured.
static void showExceptionDialog(javax.swing.JFrame frame, java.lang.String message, java.lang.String title, boolean error)
          Show display an error/warning in an JOptionPage message dialog, typically for the situation that an exception had occured.
private static void showTheDialog(javax.swing.JFrame frame, java.lang.String frameTitle, java.lang.String title, java.lang.String message, boolean error)
          Show the dialog box with given parameters; if necessary (no parent frame given), create own dummy frame to avoid that the message dialog is hidden behind other GUI frames/dialogs, and is not even visible in the task bar.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

private static final java.util.logging.Logger LOGGER

errorDuringFunctionalTest

private static java.util.List<java.lang.String> errorDuringFunctionalTest
Constructor Detail

ErrorUtils

public ErrorUtils()
Method Detail

makeStackTraceString

public static java.lang.String makeStackTraceString(java.lang.Throwable e)
Query the stacktrace items from an exception, and put them nicely into a single string.

Parameters:
e - An exception that was caught somewhere
Returns:
A string object containing all the stack trace lines.

clearErrorDuringFunctionalTest

public static void clearErrorDuringFunctionalTest()

setErrorDuringFunctionalTest

public static void setErrorDuringFunctionalTest(java.lang.String reason)
                                         throws java.lang.IllegalArgumentException
Parameters:
reason -
Throws:
java.lang.IllegalArgumentException

getErrorDuringFunctionalTest

public static java.lang.String getErrorDuringFunctionalTest()

checkErrorDuringFunctionalTest

public static boolean checkErrorDuringFunctionalTest()

exitIfStresstest

private static void exitIfStresstest()
During stress-testing, don't bother to show message, instead exit immediately:


showExceptionDialog

public static void showExceptionDialog(javax.swing.JFrame frame,
                                       java.lang.String message,
                                       java.lang.String title,
                                       boolean error)
Show display an error/warning in an JOptionPage message dialog, typically for the situation that an exception had occured. Creates a special frame for the dialog, if given frame is null. If called during stresstest, do System.exit(1) with explanatory message to logfile. If headless, display is skipped.

Parameters:
frame - A frame to be used as parent for the dialog. If null, an own frame is created for that purpose.
message - Message to be displayed in the dialog window
title - Title of the dialog window
error - If true, type is error message, for false only warning

showErrorDialog

public static void showErrorDialog(javax.swing.JFrame frame,
                                   java.lang.String title,
                                   java.lang.String message)
Show display an error/warning in an JOptionPage message dialog, but this one here typically NOT for the situation that an exception had occured. Does NOT copy anything to clipboard. Creates a special frame for the dialog, if given frame is null. If called during stresstest, do System.exit(1) with explanatory message to logfile. If headless, display is skipped.

Parameters:
frame - A frame to be used as parent for the dialog. If null, an own frame is created for that purpose.
title - Title of the dialog window
message - Message to be displayed in the dialog window

showTheDialog

private static void showTheDialog(javax.swing.JFrame frame,
                                  java.lang.String frameTitle,
                                  java.lang.String title,
                                  java.lang.String message,
                                  boolean error)
Show the dialog box with given parameters; if necessary (no parent frame given), create own dummy frame to avoid that the message dialog is hidden behind other GUI frames/dialogs, and is not even visible in the task bar.

Parameters:
frame - A parent frame to use, might be null
frameTitle - The title to use for the frame to create
title - The title for the message dialog
message - The actual message to show in the dialog
error - Type of message (true for error, false for warning)

makeDummyErrorFrame

private static javax.swing.JFrame makeDummyErrorFrame(java.lang.String frameTitle)
Creates a JFrame object which can be used as parent for a dialog; the frame is centered and contains a text telling that it is a dummy frame just for that purpose that one does not miss the message dialog.


copyToClipboard

public static boolean copyToClipboard(java.lang.String message)