task2/solution10/src/org/apidesign/apifest08/currency/CurrencyConversionException.java
1 package org.apidesign.apifest08.currency;
6 * Exception thrown in cases that a CurrencyConverter is unable ensure requested accuracy of conversion.
7 * Such situation may occur in cases that the client is not on-line, or the exchange rates are older than
8 * requested etc. This exception is defined as RuntimeException to enable simple usage in simple applications,
9 * but enable other applications to be informed about possible problems and prevent them from using
12 public final class CurrencyConversionException extends RuntimeException {
14 private final Currency from;
15 private final Currency to;
17 CurrencyConversionException(Currency from, Currency to) {
18 this(from, to, (Throwable) null);
21 CurrencyConversionException(Currency from, Currency to, Throwable throwable) {
22 this(from, to, String.format("Failed to convert curency from %1$s to %2$s", from, to), throwable);
25 CurrencyConversionException(Currency from, Currency to, String message) {
26 this(from, to, message, null);
29 CurrencyConversionException(Currency from, Currency to, String message, Throwable throwable) {
30 super(message, throwable);
35 public Currency getFromCurrency() {
39 public Currency getToCurrency() {