Class ApplicationError

  • All Implemented Interfaces:
    Serializable

    public class ApplicationError
    extends Error
    An ApplicationError should be thrown for fatal application errors, e.g., OutOfMemoryError . Such errors are not necessary to specify in the "throws" part of a message declaration. For example, errors in constructors must be thrown as an error.

    An ApplicationError extends Error with additional information. This information include the component, the key, the caller, and additional parameters. They can be used by the Logger in respect by the MessageFormatter. Especially the logger provides special methods to log an exception, see Logger.log(Level, CakeException).

    The component and the key should be defined with the same concept as for the Logger. But the exceptions are not logged automatically. To log an CakeException the exception has to be catched and logged manually:

     try {
            // some code that throws an CakeException
     } catch (CakeException ex) {
            cake.logger.LoggerFactory.getLogger(ex.getComponent()).log(Level.INFO, ex);
     }
     
    Author:
    Rainer Maximini
    See Also:
    Logger, MessageFormatter, Serialized Form
    • Constructor Detail

      • ApplicationError

        public ApplicationError​(String description)
        Only for backward compatibility, will be removed in one of the next versions.
        Parameters:
        description - An exception description.
      • ApplicationError

        public ApplicationError​(String component,
                                String key,
                                Object caller)
        Parameters:
        component - the log compoment
        key - the log key
        caller - the caller of the exception
        See Also:
        Logger
      • ApplicationError

        public ApplicationError​(String component,
                                String key,
                                Object caller,
                                Object parameter2)
        Parameters:
        component - the log compoment
        key - the log key
        caller - the caller of the exception
        See Also:
        Logger
      • ApplicationError

        public ApplicationError​(String component,
                                String key,
                                Object caller,
                                Object[] parameters)
        Parameters:
        component - the log compoment
        key - the log key
        caller - the caller of the exception
        parameters - an array of parameters
        See Also:
        Logger
      • ApplicationError

        public ApplicationError​(String component,
                                String key,
                                Object caller,
                                Object parameter1,
                                Object parameter2)
        Parameters:
        component - the log compoment
        key - the log key
        caller - the caller of the exception
        parameter1 - the first parameter
        parameter2 - the first parameter
        See Also:
        Logger
      • ApplicationError

        public ApplicationError​(String component,
                                String key,
                                Object caller,
                                Object parameter1,
                                Object parameter2,
                                Object parameter3)
        Parameters:
        component - the log compoment
        key - the log key
        caller - the caller of the exception
        parameter1 - the first parameter
        parameter2 - the first parameter
        parameter3 - the first parameter
        See Also:
        Logger
      • ApplicationError

        public ApplicationError​(String component,
                                String key,
                                Object caller,
                                Object parameter1,
                                Object parameter2,
                                Object parameter3,
                                Object parameter4)
        Parameters:
        component - the log compoment
        key - the log key
        caller - the caller of the exception
        parameter1 - the first parameter
        parameter2 - the first parameter
        parameter3 - the first parameter
        parameter4 - the first parameter
        See Also:
        Logger
    • Method Detail

      • getCaller

        public Object getCaller()
        Returns:
        Returns the caller.
      • getComponent

        public String getComponent()
        Returns:
        Returns the component.
      • getKey

        public String getKey()
        Returns:
        Returns the key.
      • getParameters

        public Object[] getParameters()
        Returns:
        Returns the parameters.