01: /*
02: * Copyright 2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
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: 348519 $ $Date: 2005-11-23 12:12:18 -0700 (Wed, 23 Nov 2005) $
25: */
26: public class FunctionEvaluationException extends MathException {
27:
28: /** Serializable version identifier */
29: private 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,
70: cause);
71: this .argument = argument;
72: }
73:
74: /**
75: * Returns the function argument that caused this exception.
76: *
77: * @return argument that caused function evaluation to fail
78: */
79: public double getArgument() {
80: return this.argument;
81: }
82: }
|