1 package org.manentia.kasai.util; 2 3 import com.koala.commons.CriticalException; 4 import com.koala.commons.NonCriticalException; 5 6 import java.util.MissingResourceException ; 7 import java.util.ResourceBundle ; 8 import org.manentia.kasai.*; 9 10 11 16 public class ExceptionUtil { 17 18 20 27 public static void throwCriticalException(String msg) 28 throws CriticalException { 29 try { 30 31 ResourceBundle messages = ResourceBundle.getBundle(Constants.MESSAGES); 32 33 throw new CriticalException(messages.getString(msg)); 34 } catch (MissingResourceException mre) { 35 throw new CriticalException(msg); 36 } 37 } 38 39 47 public static void throwCriticalException(String msg, Throwable cause) 48 throws CriticalException { 49 try { 50 51 ResourceBundle messages = ResourceBundle.getBundle(Constants.MESSAGES); 52 53 throw new CriticalException(messages.getString(msg), cause); 54 } catch (MissingResourceException mre) { 55 throw new CriticalException(msg, cause); 56 } 57 } 58 59 66 public static void throwNonCriticalException(String msg) 67 throws NonCriticalException { 68 try { 69 70 ResourceBundle messages = ResourceBundle.getBundle(Constants.MESSAGES); 71 72 throw new NonCriticalException(messages.getString(msg)); 73 } catch (MissingResourceException mre) { 74 throw new NonCriticalException(msg); 75 } 76 } 77 78 86 public static void throwNonCriticalException(String msg, Throwable cause) 87 throws NonCriticalException { 88 try { 89 90 ResourceBundle messages = ResourceBundle.getBundle(Constants.MESSAGES); 91 92 throw new NonCriticalException(messages.getString(msg), cause); 93 } catch (MissingResourceException mre) { 94 throw new NonCriticalException(msg, cause); 95 } 96 } 97 } 98
| Popular Tags
|