001: package org.manentia.kasai.util;
002:
003: import java.util.MissingResourceException;
004: import java.util.ResourceBundle;
005:
006: import org.manentia.kasai.Constants;
007:
008: import com.manentia.commons.CriticalException;
009: import com.manentia.commons.NonCriticalException;
010:
011: /**
012: * DOCUMENT ME!
013: *
014: * @author mpena
015: */
016: public class ExceptionUtil {
017:
018: //~ Metodos --------------------------------------------------------------------------------------------------------
019:
020: /**
021: * DOCUMENT ME!
022: *
023: * @param msg DOCUMENT ME!
024: *
025: * @throws CriticalException DOCUMENT ME!
026: */
027: public static void throwCriticalException(String msg)
028: throws CriticalException {
029: try {
030:
031: ResourceBundle messages = ResourceBundle
032: .getBundle(Constants.MESSAGES_PROPERTY_FILE);
033:
034: throw new CriticalException(messages.getString(msg));
035: } catch (MissingResourceException mre) {
036: throw new CriticalException(msg);
037: }
038: }
039:
040: /**
041: * DOCUMENT ME!
042: *
043: * @param msg DOCUMENT ME!
044: * @param cause DOCUMENT ME!
045: *
046: * @throws CriticalException DOCUMENT ME!
047: */
048: public static void throwCriticalException(String msg,
049: Throwable cause) throws CriticalException {
050: try {
051:
052: ResourceBundle messages = ResourceBundle
053: .getBundle(Constants.MESSAGES_PROPERTY_FILE);
054:
055: throw new CriticalException(messages.getString(msg), cause);
056: } catch (MissingResourceException mre) {
057: throw new CriticalException(msg, cause);
058: }
059: }
060:
061: /**
062: * DOCUMENT ME!
063: *
064: * @param msg DOCUMENT ME!
065: *
066: * @throws NonCriticalException DOCUMENT ME!
067: */
068: public static void throwNonCriticalException(String msg)
069: throws NonCriticalException {
070: try {
071:
072: ResourceBundle messages = ResourceBundle
073: .getBundle(Constants.MESSAGES_PROPERTY_FILE);
074:
075: throw new NonCriticalException(messages.getString(msg));
076: } catch (MissingResourceException mre) {
077: throw new NonCriticalException(msg);
078: }
079: }
080:
081: /**
082: * DOCUMENT ME!
083: *
084: * @param msg DOCUMENT ME!
085: * @param cause DOCUMENT ME!
086: *
087: * @throws NonCriticalException DOCUMENT ME!
088: */
089: public static void throwNonCriticalException(String msg,
090: Throwable cause) throws NonCriticalException {
091: try {
092:
093: ResourceBundle messages = ResourceBundle
094: .getBundle(Constants.MESSAGES_PROPERTY_FILE);
095:
096: throw new NonCriticalException(messages.getString(msg),
097: cause);
098: } catch (MissingResourceException mre) {
099: throw new NonCriticalException(msg, cause);
100: }
101: }
102: }
|