Class ApplicationException

    • Constructor Detail

      • ApplicationException

        public ApplicationException​(String message)
        The constructor.
        Parameters:
        message - the message describing the problem briefly.
      • ApplicationException

        public ApplicationException​(Localizable message)
        The constructor.
        Parameters:
        message - the message describing the problem briefly.
      • ApplicationException

        public ApplicationException​(String message,
                                    Throwable cause)
        The constructor.
        Parameters:
        message - the message describing the problem briefly.
        cause - is the cause of this exception.
      • ApplicationException

        public ApplicationException​(Localizable message,
                                    Throwable cause)
        The constructor.
        Parameters:
        message - the message describing the problem briefly.
        cause - is the cause of this exception.
      • ApplicationException

        protected ApplicationException​(String message,
                                       Throwable cause,
                                       UUID uuid)
        The constructor.
        Parameters:
        message - the message describing the problem briefly.
        cause - is the cause of this exception. May be null.
        uuid - the explicit UUID or null to initialize by default (from given Throwable or as new UUID).
      • ApplicationException

        protected ApplicationException​(Localizable message,
                                       Throwable cause,
                                       UUID uuid)
        The constructor.
        Parameters:
        message - the message describing the problem briefly.
        cause - is the cause of this exception. May be null.
        uuid - the explicit UUID or null to initialize by default (from given Throwable or as new UUID).
    • Method Detail

      • getUuid

        public final UUID getUuid()
        This method gets the UUID of this ApplicationException. When a new ApplicationException is created, a UUID is assigned. In case the ApplicationException is created from another ApplicationException as cause, the existing UUID will be used from that cause. Otherwise a new UUID is generated.
        The UUID will appear in the stacktrace but NOT in the message. It will therefore be written to log-files if this exception is logged. If you supply the UUID to the end-user, he can provide it with the problem report so an administrator or software developer can easily find the stacktrace in the log-files.
        Returns:
        the UUID of this object.
      • getLocalizedMessage

        public String getLocalizedMessage​(Locale locale)
        Description copied from interface: Localizable
        This method gets the resolved and localized message.
        Specified by:
        getLocalizedMessage in interface Localizable
        Parameters:
        locale - is the locale to translate to.
        Returns:
        the localized message.
      • printStackTrace

        public void printStackTrace​(Locale locale,
                                    Appendable buffer)
        This method prints the stack trace with localized exception message(s).
        Parameters:
        locale - is the locale to translate to.
        buffer - is where to write the stack trace to.
        Throws:
        IllegalStateException - if the given buffer produced an IOException.
      • isTechnical

        public boolean isTechnical()
        Determines if this is a technical exception.
        • A technical exception is an unexpected situation that is to be logged on error level and should be analyzed by the operators or software developers of the system. Further in such case the end-user can typically do nothing about the problem (except to retry his operation) and will typically not understand the problem. Therefore a generic message should be displayed to the end-user in such case.
        • A non technical exception is called user failure. It is an undesired but NOT abnormal situation (e.g. a mandatory field was not filled). It should be logged on a level less than error (typically info). The message is typically intended for to end-users and has to be easy to understand.
        This separation is intentionally not done via inheritance of technical and business exception base classes to allow reuse. However, if you want to have it this way, create such classes on your own derived from this class.
        Returns:
        true if this is a technical exception, false if this is a user error.
        See Also:
        isForUser()
      • isForUser

        public boolean isForUser()
        Note: Please consider using net.sf.mmm.nls.exception.NlsException with i18n support in case you are creating exceptions for end-users.
        Returns:
        true if the message of this exception is for end-users (or clients), false otherwise (for internal technical errors).
      • getCode

        public String getCode()
        This method gets the code that identifies the detailed type of this object. While UUID is unique per instance of a ApplicationException this code is a short and readable identifier representing the ApplicationException Class. The default implementation returns the simple name. However, the code should remain stable after refactoring (so at least after the rename the previous code should be returned as String literal). This code may be used as a compact identifier to reference the related problem or information as well as for automatic tests of error situations that should remain stable even if the message text gets improved or the locale is unknown.
        Returns:
        the error code.