Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  // @(#) $Id: BRNotificationBox.java 2084 2007-11-27 14:53:31Z s3460 $
Copyright (c) 2003, 2007 s IT Solutions AT Spardat GmbH . All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: s IT Solutions AT Spardat GmbH - initial API and implementation /
 
 package at.spardat.xma.boot;
 
 
 
Utility methods to display boot runtime exceptions

Author(s):
CGS
 
 public class BRNotificationBox {

    
Shows a java.lang.Throwable in a modal message box.

Parameters:
throwable a Throwable to show
 
     public static void show (Throwable throwable) {
         if (throwable==null)  return;
 
         try {
 
         String        title    = BRTCodes.getText. );
         StringBuffer  text     = new StringBuffer();
 
         if (throwable instanceof BootRuntimeException) {
 
             BootRuntimeException brtEx = (BootRuntimeException)throwable;
 
             ifbrtEx.getShowToEndUser() == false ) {
                 return;
             }
 
             appendCodebrtEx.getCode(), text );
             text.appendbrtEx.getLocalizedMessage() );

            
decide if the stacktrace of the BaseException should be shown
 
 //            boolean verboseOutput;
 //            if (verboseOutput) {
 //                text.append("\n\nException Stacktrace (not displayed in non-development environments):\n");
 //                appendStacktraceOf(appEx, text);
 //            }
         } else if (throwable instanceof Throwable) {
             String strGeneralAppError = BRTCodes.getText(.);
             String strReason          = BRTCodes.getText(.);
             int iCode = .;
             appendCode(iCode,text);
             text.append(strGeneralAppError);
 
             text.append("\n\n" + strReason + ": \"" + throwable.toString() + "\"");
         }
 
 
         // append reference to log file
         try {
             Properties props = Launcher.getBootRuntimeProperties();
             if(props!=null && "true".equalsIgnoreCase(props.getProperty("boot.showloghint"))) {
                 String logFileName = LogManager.getLogManager().getLogFileName();
                 if(logFileName!=null&&logFileName.length()>0) {
                     MessageFormat format = new MessageFormat(BRTCodes.getText(.));
                     text.append('\n').append(format.format(new Object[]{logFileName}));
                 }
             }
         } catch (Exception e) {
             e.printStackTrace();
         }

        
construct MessageBox and show
 
         JOptionPane.showMessageDialog(null,text.toString(),title,.);
 
         } catch(Exception ex ) {
             ..println"exception on show error: " + ex.toString() );
         }
 
     }
 
     private static void appendCodeint iCodeStringBuffer buffer ){
         if ( iCode != 0 && buffer!=null) {
            buffer.append("[");
            buffer.appendiCode );
            buffer.append("]: ");
        }
    }
New to GrepCode? Check out our FAQ X