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 edu.umd.cs.findbugs.annotations.NonNull;
10
11 /**
12 * FODF: Exceptions related to formatting errors in Metapath functions such as
13 * {@code format-integer}, {@code format-number}, {@code format-dateTime}, and
14 * {@code format-date}.
15 */
16 public class FormatFunctionException
17 extends FunctionMetapathError {
18 @NonNull
19 private static final String PREFIX = "FODF";
20 /**
21 * <a href=
22 * "https://www.w3.org/TR/xpath-functions-31/#ERRFODF1310">err:FODF1310</a>:
23 * Raised when a format token in a picture string is invalid.
24 */
25 public static final int INVALID_FORMAT_TOKEN = 1310;
26
27 /**
28 * the serial version UID.
29 */
30 private static final long serialVersionUID = 1L;
31
32 /**
33 * Constructs a new exception with the provided {@code code}, {@code message},
34 * and no cause.
35 *
36 * @param code
37 * the error code value
38 * @param message
39 * the exception message
40 */
41 public FormatFunctionException(int code, String message) {
42 super(IErrorCode.of(PREFIX, code), message);
43 }
44
45 /**
46 * Constructs a new exception with the provided {@code code}, {@code message},
47 * and {@code cause}.
48 *
49 * @param code
50 * the error code value
51 * @param message
52 * the exception message
53 * @param cause
54 * the original exception cause
55 */
56 public FormatFunctionException(int code, String message, Throwable cause) {
57 super(IErrorCode.of(PREFIX, code), message, cause);
58 }
59
60 /**
61 * Constructs a new exception with the provided {@code code}, no message, and
62 * the {@code cause}.
63 *
64 * @param code
65 * the error code value
66 * @param cause
67 * the original exception cause
68 */
69 public FormatFunctionException(int code, Throwable cause) {
70 super(IErrorCode.of(PREFIX, code), cause);
71 }
72 }