1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.math;
17
18 /***
19 * Exeption thrown when an error occurs evaluating a function.
20 * <p>
21 * Maintains an <code>argument</code> property holding the input value that
22 * caused the function evaluation to fail.
23 *
24 * @version $Revision: 1.2 $ $Date: 2004/07/17 21:12:52 $
25 */
26 public class FunctionEvaluationException extends MathException {
27
28 /*** Serializable version identifier */
29 static final long serialVersionUID = -317289374378977972L;
30
31 /*** Argument causing function evaluation failure */
32 private double argument = Double.NaN;
33
34 /***
35 * Construct an exception indicating the argument value
36 * that caused the function evaluation to fail. Generates an exception
37 * message of the form "Evaluation failed for argument = " + argument.
38 *
39 * @param argument the failing function argument
40 */
41 public FunctionEvaluationException(double argument) {
42 this(argument, "Evaluation failed for argument = " + argument);
43 }
44
45 /***
46 * Construct an exception using the given argument and message
47 * text. The message text of the exception will start with
48 * <code>message</code> and be followed by
49 * " Evaluation failed for argument = " + argument.
50 *
51 * @param argument the failing function argument
52 * @param message the exception message text
53 */
54 public FunctionEvaluationException(double argument, String message) {
55 this(argument, message, null);
56 }
57
58 /***
59 * Construct an exception with the given argument, message and root cause.
60 * The message text of the exception will start with <code>message</code>
61 * and be followed by " Evaluation failed for argument = " + argument.
62 *
63 * @param argument the failing function argument
64 * @param message descriptive error message
65 * @param cause root cause.
66 */
67 public FunctionEvaluationException(double argument, String message,
68 Throwable cause) {
69 super(message + " Evaluation failed for argument=" + argument, cause);
70 this.argument = argument;
71 }
72
73 /***
74 * Returns the function argument that caused this exception.
75 *
76 * @return argument that caused function evaluation to fail
77 */
78 public double getArgument() {
79 return this.argument;
80 }
81 }