1 /*
2 * SPDX-FileCopyrightText: none
3 * SPDX-License-Identifier: CC0-1.0
4 */
5
6 package dev.metaschema.core.metapath.function;
7
8 import dev.metaschema.core.metapath.IErrorCode;
9 import dev.metaschema.core.metapath.function.library.FnResolveUri;
10 import edu.umd.cs.findbugs.annotations.NonNull;
11
12 /**
13 * FONS: Exceptions related to function namespaces.
14 */
15 public class UriFunctionException
16 extends FunctionMetapathError {
17 @NonNull
18 private static final String PREFIX = "FONS";
19 /**
20 * <a href=
21 * "https://www.w3.org/TR/xpath-functions-31/#ERRFONS0004">err:FONS0004</a>:
22 * Raised by <a href=
23 * "https://www.w3.org/TR/xpath-functions-31/#func-resolve-QName">fn:resolve-QName</a>
24 * and analogous functions if a supplied QName has a prefix that has no binding
25 * to a namespace.
26 */
27 public static final int NO_NAMESPACE_FOUND_FOR_PREFIX = 4;
28 /**
29 * <a href=
30 * "https://www.w3.org/TR/xpath-functions-31/#ERRFONS0005">err:FONS0005</a>:
31 * Raised by {@link FnResolveUri} if no base URI is available for resolving a
32 * relative URI.
33 */
34 public static final int BASE_URI_NOT_DEFINED_IN_STATIC_CONTEXT = 5;
35
36 /**
37 * the serial version UID.
38 */
39 private static final long serialVersionUID = 2L;
40
41 /**
42 * Constructs a new exception with the provided {@code code}, {@code message},
43 * and no cause.
44 *
45 * @param code
46 * the error code value
47 * @param message
48 * the exception message
49 */
50 public UriFunctionException(int code, String message) {
51 super(IErrorCode.of(PREFIX, code), message);
52 }
53
54 /**
55 * Constructs a new exception with the provided {@code code}, {@code message},
56 * and {@code cause}.
57 *
58 * @param code
59 * the error code value
60 * @param message
61 * the exception message
62 * @param cause
63 * the original exception cause
64 */
65 public UriFunctionException(int code, String message, Throwable cause) {
66 super(IErrorCode.of(PREFIX, code), message, cause);
67 }
68
69 /**
70 * Constructs a new exception with the provided {@code code}, no message, and
71 * the {@code cause}.
72 *
73 * @param code
74 * the error code value
75 * @param cause
76 * the original exception cause
77 */
78 public UriFunctionException(int code, Throwable cause) {
79 super(IErrorCode.of(PREFIX, code), cause);
80 }
81 }