Глава 22. Обработка исключительных ситуаций_______________________637
string Why() const { return strTheReason; ) ErrorCode GetErrorCode() const { return TheError; }
private:
string strTheReason;
ErrorCode TheError;
};
// Классы конкретных исключительных ситуаций class ExpenseTooSmall : public ExpException ( public;
ExpenseTooSmall() :
ExpException(EXP_ERR_EXPENSE_TOO_SMALL,
"Expense item under the minimum amount eligible " / "for reimbursement.") ( } };
class ExpenseTooLarge : public ExpException »
(
public:
ExpenseTooLarge() :
ExpExcept ion(EXP_ERR_EXPENSE_TOO_LARGE,
"Expense item greater than the maximum amount " "eligible for reimbursement.")
( } • };
class EmployeeException : public ExpException
{
public:
EmployeeException(ErrorCode NewErrorCode, unsigned NewEmployeeID, const char* NewReason = NULL) :
ExpException(NewErrorCode, NewReason), EmployeeID(NewEmployeeID) { }
unsigned GetEmployeeIDO const { return EmployeeID; } private:
unsigned EmployeeID;
};
class NoExpenseItems : public EmployeeException
{
public:
NoExpenseItems(unsigned NewEmployeeID) :
EmployeeException(EXP_ERR_NO_EXPENSE_ITEMS, NewEmployeeID,
"No expense items for.this employee") { )