1 /* 2 * Conditions Of Use 3 * 4 * This software was developed by employees of the National Institute of 5 * Standards and Technology (NIST), an agency of the Federal Government. 6 * Pursuant to title 15 Untied States Code Section 105, works of NIST 7 * employees are not subject to copyright protection in the United States 8 * and are considered to be in the public domain. As a result, a formal 9 * license is not needed to use the software. 10 * 11 * This software is provided by NIST as a service and is expressly 12 * provided "AS IS." NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED 13 * OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF 14 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT 15 * AND DATA ACCURACY. NIST does not warrant or make any representations 16 * regarding the use of the software or the results thereof, including but 17 * not limited to the correctness, accuracy, reliability or usefulness of 18 * the software. 19 * 20 * Permission to use this software is contingent upon your acceptance 21 * of the terms of this agreement 22 * 23 * . 24 * 25 */ 26 /******************************************************************************* 27 * Product of NIST/ITL Advanced Networking Technologies Division (ANTD). * 28 *******************************************************************************/ 29 package gov.nist.core; 30 /** 31 * Handle Internal error failures and print a stack trace (for debugging). 32 * 33 *@version 1.2 34 * 35 *@author M. Ranganathan <br/> 36 * 37 * 38 * 39 */ 40 public class InternalErrorHandler { 41 42 public static void handleException(Exception ex) throws RuntimeException { 43 System.err.println ("Unexpected internal error FIXME!! " + ex.getMessage()); 44 ex.printStackTrace(); 45 throw new RuntimeException("Unexpected internal error FIXME!! " + ex.getMessage(), ex); 46 47 } 48 /** 49 * Handle an unexpected exception. 50 */ 51 public static void handleException(Exception ex, StackLogger stackLogger) { 52 System.err.println ("Unexpected internal error FIXME!! " + ex.getMessage()); 53 stackLogger.logError("UNEXPECTED INTERNAL ERROR FIXME " + ex.getMessage()); 54 ex.printStackTrace(); 55 stackLogger.logException(ex); 56 throw new RuntimeException("Unexpected internal error FIXME!! " + ex.getMessage(), ex); 57 58 } 59 /** 60 * Handle an unexpected condition (and print the error code). 61 */ 62 63 public static void handleException(String emsg) { 64 new Exception().printStackTrace(); 65 System.err.println("Unexepcted INTERNAL ERROR FIXME!!"); 66 System.err.println(emsg); 67 throw new RuntimeException(emsg); 68 69 } 70 71 public static void handleException(String emsg, StackLogger stackLogger) { 72 stackLogger.logStackTrace(); 73 stackLogger.logError("Unexepcted INTERNAL ERROR FIXME!!"); 74 stackLogger.logFatalError(emsg); 75 throw new RuntimeException(emsg); 76 77 } 78 } 79