CRangeError

Name

CRangeError -- Reports and exception for a value out of allowed range.

Synopsis


#include <CRangeError.h>
class           CRangeError {
                
  CRangeError(Int_t nLow, Int_t nHigh, Int_t nRequested, const char* pDoing);
                  CRangeError(Int_t nLow, Int_t nHigh, Int_t nRequested, const std::string& rDoing);
                
  virtual   const const char* ReasonText();
                  virtual const Int_t ReasonCode();
};
             

Description

Provides an exception that can be used to report parameter range errors (normally for integer parameters). The exception will construct a reason text that includes the erroneous value as well as the valid range of values.

Public member functions

CRangeError(Int_t nLow, Int_t nHigh, Int_t nRequested, const char* pDoing); CRangeError(Int_t nLow, Int_t nHigh, Int_t nRequested, const std::string& rDoing);

Creates a CRangeError that can be thrown. The only difference between the two constructors is the way in which the context information is passed. In the first, by a standard C null terminated string. In the second by a C++ std::string object.

The remaining parameters describe the actual exceptional condition:

nLow

Is the low end of the allowed range that was violated.

nHigh

Is the high end of the allowed range that was violated.

nRequested

Is the value that violated the range described by nLow and nHigh

virtual const const char* ReasonText();

Returns the reason for the exception. This will be a string of the form: Range error: %v is outside the range [%l..%h] where %v, %l %h are shorthands for the value, low and high limits respectively.

virtual const Int_t ReasonCode();

Returns one of the two possible reasons for the exception:

CRangeError::knTooHigh

The value requested was above the upper limit of the range.

CRangeError::knTooLow

The value requested was below the lower limit of the range.

Note that if the requested value provided to the constuctor does not satisfy either of these relationships, invoking this member function will result in an assertion failure.