1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package org.apache.commons.numbers.fraction;
18
19 /**
20 * Package private exception class with constants for frequently used messages.
21 */
22 class FractionException extends ArithmeticException {
23
24 /** Error message for overflow during conversion. */
25 static final String ERROR_CONVERSION_OVERFLOW = "Overflow trying to convert %s to fraction (%d/%d)";
26 /** Error message when iterative conversion fails. */
27 static final String ERROR_CONVERSION = "Unable to convert %s to fraction after %d iterations";
28 /** Error message for zero-valued denominator. */
29 static final String ERROR_ZERO_DENOMINATOR = "Denominator must be different from 0";
30 /** Error message for divide by zero. */
31 static final String ERROR_DIVIDE_BY_ZERO = "The value to divide by must not be zero";
32
33 /** Serializable version identifier. */
34 private static final long serialVersionUID = 201701191744L;
35
36 /**
37 * Create an exception where the message is constructed by applying
38 * {@link String#format(String, Object...)}.
39 *
40 * @param message the exception message format string
41 * @param formatArguments the arguments for formatting the message
42 */
43 FractionException(String message, Object... formatArguments) {
44 super(String.format(message, formatArguments));
45 }
46
47 /**
48 * Create an exception with the specified message.
49 *
50 * @param message the exception message
51 */
52 FractionException(String message) {
53 super(message);
54 }
55 }