Rogue Wave banner
Previous fileTop of DocumentContentsIndexNext file

8.1 Overview

In C++, operations on RWDecimal classes can result in three general types of error:

In the Money.h++ C++ library, if an overflow or an inexact error occurs during one of the three exact arithmetic operations, an error handler is called. The default overflow error handler throws an RWDecimalOverflowErr<T> exception object, or prints an error and exits if your compiler doesn't support exceptions. The default inexact error handler prints an error message but does not exit. In Section 8.4, we'll describe how to change these default behaviors.

In the Money.h++ Java library, these three conditions result in a call to the error handler with a PrecisionExceededException error, described in the API documentation. Section 8.4.3 describes how to adjust the behavior of the error handler.

Remember, in both Java and C++ you can perform operations on different currencies if you use a money calculator object. However, if you an attempt to perform an arithmetic operation in C++ on RWMoney objects of different currencies the operator throws an RWExternalError exception. See the Tools.h++ documentation for information on RWExternalError. In Java, attempting to use two Money objects of different currencies in a calculation calls the error handler with MismatchedCurrenciesException.

In C++ if the factory cannot create an exchange object, it returns an invalid exchange object. If the same problem occurs in Java, the factory returns a null value. Java applications send an InvalidExchangeException error to the error handler if an illogical exchange object is requested from the ExchangeFactory, for example, if you request a conversion from French Francs to French Francs. An InvalidExchangeException error also occurs if the MoneyCalculator is asked to make a currency conversion and is unable to find an appropriate currency exchange object.


Previous fileTop of DocumentContentsIndexNext file

©Copyright 1999, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.