PeterO.Numbers.ETrapException
## PeterO.Numbers.ETrapException
public sealed class ETrapException : System.ArithmeticException, System.Runtime.Serialization.ISerializable
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.
Member Summary
[Context](#Context)
- Gets the arithmetic context used during the operation that triggered the trap.[Error](#Error)
- Gets the flag that specifies the primary kind of error in one or more operations (EContext.[Errors](#Errors)
- Gets the flags that were signaled as the result of one or more operations.[HasError(int)](#HasError_int)
- Returns whether this trap exception specifies all the flags given.[Result](#Result)
- Gets the defined result of the operation that caused the trap.
### ETrapException Constructor
public ETrapException( int flag, PeterO.Numbers.EContext ctx, object result);
Initializes a new instance of the PeterO.Numbers.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 Constructor
public ETrapException( int flags, int flag, PeterO.Numbers.EContext ctx, object result);
Initializes a new instance of the PeterO.Numbers.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 beEContext.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.
Exceptions:
- System.ArgumentException: The parameter flags doesn’t include all the flags in the flag parameter.
### ETrapException Constructor
public ETrapException( string message, System.Exception innerException);
Initializes a new instance of the PeterO.Numbers.ETrapException class.
Parameters:
-
message: The parameter message is a text string.
-
innerException: The parameter innerException is an Exception object.
### ETrapException Constructor
public ETrapException( string message);
Initializes a new instance of the PeterO.Numbers.ETrapException class.
Parameters:
- message: The parameter message is a text string.
### ETrapException Constructor
public ETrapException();
Initializes a new instance of the PeterO.Numbers.ETrapException class.
public PeterO.Numbers.EContext Context { get; }
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.
public int Error { get; }
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.
public int Errors { get; }
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.
public object Result { get; }
Gets the defined result of the operation that caused the trap.
Returns:
The defined result of the operation that caused the trap.
public bool 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
.
Return Value:
True if this exception pertains to all of the flags given in flag ; otherwise, false.