#include <CInvalidArgumentException.h>
class CInvalidArgumentException {CInvalidArgumentException(std::string argument, std::string whybad, std::string wasDoing);
CInvalidArgumentException(const CInvalidArgumentException& rhs);
virtual ~CInvalidArgumentException();
CInvalidArgumentException& operator=(const CInvalidArgumentException& rhs);
const int operator==(const CInvalidArgumentException& rhs);
const int operator!=(const CInvalidArgumentException& rhs);
virtual const const char* ReasonText();
}
While
CRangeError
provides an exception that can be thrown if values passed to a function
are out of bounds, other argument errors are possible.
Consider a function that takes a string and converts it to an integer.
If the string cannot be converted, this represents an error in the
argument, but CRangeError
is not the
appropriate exception.
CInvalidArgumentException
provides a
class that can be thrown for arbitrary problems with parameters.
The thrower must be able to create a textual equivalent of the bad argument, a string that describes why the argument is bad as well as supplying the usual context string.
CInvalidArgumentException(std::string argument, std::string whybad, std::string wasDoing);
This is the constructor typically used to create a
CInvalidArgumentException
.
argument
is a textual representation of the
bad argument.
whybad
is a text string that describes
why the argument was bad. wasDoing
is the context string that all exception objects require.
CInvalidArgumentException(const CInvalidArgumentException& rhs);
Provides for copy construction of
CInvalidArgumentException
objects.
CInvalidArgumentException& operator=(const CInvalidArgumentException& rhs);
Provides for assignment to an object from another
CInvalidArgumentException
object;
rhs
.
const int operator==(const CInvalidArgumentException& rhs);
Provides for the ability to check for equality between
rhs
and a left hand side object.
const int operator!=(const CInvalidArgumentException& rhs);
Provides for the ability to check for inequality.
virtual const const char* ReasonText();
Constructs and returns a pointer to a string that describes the error. This string should not be deleted by the caller.