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.math4.neuralnet.internal;
18
19 import java.text.MessageFormat;
20
21 /**
22 * Exception class with constants for frequently used messages.
23 */
24 public class NeuralNetException extends IllegalArgumentException {
25 /** Error message for "out of range" condition. */
26 public static final String OUT_OF_RANGE = "Number {0} is out of range [{1}, {2}]";
27 /** Error message for "not strictly positive" condition. */
28 public static final String NOT_STRICTLY_POSITIVE = "Number {0} is not strictly positive";
29 /** Error message for "too large" condition. */
30 public static final String TOO_LARGE = "Number {0} is larger than {1}";
31 /** Error message for "too small" condition. */
32 public static final String TOO_SMALL = "Number {0} is smaller than {1}";
33 /** Error message for "out of range" condition. */
34 public static final String NO_DATA = "No data";
35 /** Error message for "size mismatch" condition. */
36 public static final String SIZE_MISMATCH = "Size mismatch: {0} != {1}";
37 /** Error message for "identifier already used" condition. */
38 public static final String ID_IN_USE = "Identifier already in use: {0}";
39 /** Error message for "identifier not found" condition. */
40 public static final String ID_NOT_FOUND = "Identifier not found: {0}";
41
42 /** Serializable version identifier. */
43 private static final long serialVersionUID = 20210515L;
44
45 /**
46 * Create an exception where the message is constructed by applying
47 * the {@code format()} method from {@code java.text.MessageFormat}.
48 *
49 * @param message Message format (with replaceable parameters).
50 * @param formatArguments Actual arguments to be displayed in the message.
51 */
52 public NeuralNetException(String message, Object... formatArguments) {
53 super(MessageFormat.format(message, formatArguments));
54 }
55 }