Class ETrapException

  • All Implemented Interfaces:
    java.io.Serializable

    public final class ETrapException
    extends java.lang.ArithmeticException
    Exception thrown for arithmetic trap errors. (The "E" stands for "extended", and has this prefix to group it with the other classes common to this library, particularly EDecimal, EFloat, and ERational.).

    This library may throw exceptions of this type in certain cases, notably when errors occur, and may supply messages to those exceptions (the message can be accessed through the Message property in.NET or the getMessage() method in Java). These messages are intended to be read by humans to help diagnose the error (or other cause of the exception); they are not intended to be parsed by computer programs, and the exact text of the messages may change at any time between versions of this library.

    See Also:
    Serialized Form
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      EContext getContext()
      Gets the arithmetic context used during the operation that triggered the trap.
      int getError()
      Gets the flag that specifies the primary kind of error in one or more operations (EContext.FlagXXX).
      int getErrors()
      Gets the flags that were signaled as the result of one or more operations.
      java.lang.Object getResult()
      Gets the defined result of the operation that caused the trap.
      boolean HasError​(int flag)
      Returns whether this trap exception specifies all the flags given.
      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • ETrapException

        public ETrapException()
        Initializes a new instance of the ETrapException class.
      • ETrapException

        public ETrapException​(java.lang.String message)
        Initializes a new instance of the ETrapException class.
        Parameters:
        message - The parameter message is a text string.
      • ETrapException

        public ETrapException​(java.lang.String message,
                              java.lang.Throwable innerException)
        Initializes a new instance of the ETrapException class.
        Parameters:
        message - The parameter message is a text string.
        innerException - The parameter innerException is an Exception object.
      • ETrapException

        public ETrapException​(int flag,
                              EContext ctx,
                              java.lang.Object result)
        Initializes a new instance of the ETrapException class.
        Parameters:
        flag - The flag that specifies the kind of error from one or more operations (EContext.FlagXXX). This will only be one flag, such as FlagInexact or FlagSubnormal.
        ctx - The arithmetic context used during the operation that triggered the trap. Can be null.
        result - The defined result of the operation that caused the trap.
      • ETrapException

        public ETrapException​(int flags,
                              int flag,
                              EContext ctx,
                              java.lang.Object result)
        Initializes a new instance of the ETrapException class.
        Parameters:
        flags - Specifies the flags that were signaled as the result of one or more operations. This includes the flag specified in the "flag" parameter, but can include other flags. For instance, if "flag" is EContext.FlagInexact, this parameter might be EContext.FlagInexact | EContext.FlagRounded.
        flag - Specifies the flag that specifies the primary kind of error from one or more operations (EContext.FlagXXX). This will only be one flag, such as FlagInexact or FlagSubnormal.
        ctx - The arithmetic context used during the operation that triggered the trap. Can be null.
        result - The defined result of the operation that caused the trap.
        Throws:
        java.lang.IllegalArgumentException - The parameter flags doesn't include all the flags in the flag parameter.
    • Method Detail

      • getContext

        public final EContext getContext()
        Gets the arithmetic context used during the operation that triggered the trap. May be null.
        Returns:
        The arithmetic context used during the operation that triggered the trap. May be null.
      • getResult

        public final java.lang.Object getResult()
        Gets the defined result of the operation that caused the trap.
        Returns:
        The defined result of the operation that caused the trap.
      • getError

        public final int getError()
        Gets the flag that specifies the primary kind of error in one or more operations (EContext.FlagXXX). This will only be one flag, such as FlagInexact or FlagSubnormal.
        Returns:
        The flag that specifies the primary kind of error in one or more operations.
      • getErrors

        public final int getErrors()
        Gets the flags that were signaled as the result of one or more operations. This includes the flag specified in the "flag" parameter, but can include other flags. For instance, if "flag" is EContext.FlagInexact, this parameter might be EContext.FlagInexact | EContext.FlagRounded.
        Returns:
        The flags that specify the errors in one or more operations.
      • HasError

        public boolean HasError​(int flag)
        Returns whether this trap exception specifies all the flags given. (Flags are signaled in a trap exception as the result of one or more operations involving arbitrary-precision numbers, such as multiplication of two EDecimals.).
        Parameters:
        flag - A combination of one or more flags, such as EContext.FlagInexact | EContext.FlagRounded.
        Returns:
        True if this exception pertains to all of the flags given in flag ; otherwise, false.