1 /*
2 * SPDX-FileCopyrightText: none
3 * SPDX-License-Identifier: CC0-1.0
4 */
5
6 package gov.nist.secauto.metaschema.core.metapath.function;
7
8 import gov.nist.secauto.metaschema.core.metapath.IErrorCode;
9
10 import edu.umd.cs.findbugs.annotations.NonNull;
11
12 /**
13 * FORG: Exceptions related to argument types.
14 */
15 public class InvalidArgumentFunctionException
16 extends FunctionMetapathError {
17 @NonNull
18 private static final String PREFIX = "FORG";
19
20 /**
21 * <a href=
22 * "https://www.w3.org/TR/xpath-functions-31/#ERRFORG0001">err:FORG0001</a>: A
23 * general-purpose error raised when casting, if a cast between two datatypes is
24 * allowed in principle, but the supplied value cannot be converted: for example
25 * when attempting to cast the string "nine" to an integer.
26 */
27 public static final int INVALID_VALUE_FOR_CAST = 1;
28 /**
29 * <a href=
30 * "https://www.w3.org/TR/xpath-functions-31/#ERRFORG0002">err:FORG0002</a>:
31 * Raised when either argument to fn:resolve-uri is not a valid URI/IRI.
32 */
33 public static final int INVALID_ARGUMENT_TO_RESOLVE_URI = 2;
34 /**
35 * <a href=
36 * "https://www.w3.org/TR/xpath-functions-31/#ERRFORG0003">err:FORG0003</a>:
37 * Raised by <a href=
38 * "https://www.w3.org/TR/xpath-functions-31/#func-zero-or-one">fn:zero-or-one</a>
39 * if the supplied value contains more than one item.
40 *
41 */
42 public static final int INVALID_ARGUMENT_ZERO_OR_ONE = 3;
43 /**
44 * <a href=
45 * "https://www.w3.org/TR/xpath-functions-31/#ERRFORG0004">err:FORG0005</a>:
46 * Raised by <a href=
47 * "https://www.w3.org/TR/xpath-functions-31/#func-one-or-more">fn:one-or-more</a>
48 * if the supplied value is an empty sequence.
49 */
50 public static final int INVALID_ARGUMENT_ONE_OR_MORE = 4;
51 /**
52 * <a href=
53 * "https://www.w3.org/TR/xpath-functions-31/#ERRFORG0005">err:FORG0005</a>:
54 * Raised by <a href=
55 * "https://www.w3.org/TR/xpath-functions-31/#func-exactly-one">fn:exactly-one</a>
56 * if the supplied value is not a singleton sequence.
57 *
58 */
59 public static final int INVALID_ARGUMENT_EXACTLY_ONE = 5;
60 /**
61 * <a href=
62 * "https://www.w3.org/TR/xpath-functions-31/#ERRFORG0006">err:FORG0006</a>:
63 * Raised by functions such as
64 * <a href="https://www.w3.org/TR/xpath-functions-31/#func-max">fn:max</a>,
65 * <a href="https://www.w3.org/TR/xpath-functions-31/#func-min">fn:min</a>,
66 * <a href="https://www.w3.org/TR/xpath-functions-31/#func-avg">fn:avg</a>,
67 * <a href="https://www.w3.org/TR/xpath-functions-31/#func-sum">fn:sum</a> if
68 * the supplied sequence contains values inappropriate to this function.
69 */
70 public static final int INVALID_ARGUMENT_TYPE = 6;
71
72 /**
73 * <a href=
74 * "https://www.w3.org/TR/xpath-functions-31/#ERRFORG0008">err:FORG0008</a>:
75 * Raised by <a href=
76 * "https://www.w3.org/TR/xpath-functions-31/#func-dateTime">fn:dateTime</a> if
77 * the two arguments both have timezones and the timezones are different.
78 */
79 public static final int DATE_TIME_INCONSISTENT_TIMEZONE = 8;
80
81 /**
82 * the serial version UUID.
83 */
84 private static final long serialVersionUID = 1L;
85
86 /**
87 * Constructs a new exception with the provided {@code code}, {@code message},
88 * and {@code cause}.
89 *
90 * @param code
91 * the error code value
92 * @param message
93 * the exception message
94 * @param cause
95 * the original exception cause
96 */
97 public InvalidArgumentFunctionException(int code, String message, Throwable cause) {
98 super(IErrorCode.of(PREFIX, code), message, cause);
99 }
100
101 /**
102 * Constructs a new exception with the provided {@code code}, {@code message},
103 * and no cause.
104 *
105 * @param code
106 * the error code value
107 * @param message
108 * the exception message
109 */
110 public InvalidArgumentFunctionException(int code, String message) {
111 super(IErrorCode.of(PREFIX, code), message);
112 }
113
114 /**
115 * Constructs a new exception with the provided {@code code}, no message, and
116 * the {@code cause}.
117 *
118 * @param code
119 * the error code value
120 * @param cause
121 * the original exception cause
122 */
123 public InvalidArgumentFunctionException(int code, Throwable cause) {
124 super(IErrorCode.of(PREFIX, code), cause);
125 }
126 }