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   * FOFD: Exceptions related to errors in formatting date/time values.
13   *
14   * @see <a href="https://www.w3.org/TR/xpath-functions-31/#formatting-dates">
15   *      XPath Functions 3.1 - Formatting Dates and Times</a>
16   */
17  public class FormatDateTimeFunctionException
18      extends FunctionMetapathError {
19    @NonNull
20    private static final String PREFIX = "FOFD";
21    /**
22     * <a href=
23     * "https://www.w3.org/TR/xpath-functions-31/#ERRFOFD1340">err:FOFD1340</a>:
24     * Raised when the picture string supplied to a date/time formatting function
25     * does not conform to the required syntax.
26     */
27    public static final int INVALID_PICTURE_STRING = 1340;
28    /**
29     * <a href=
30     * "https://www.w3.org/TR/xpath-functions-31/#ERRFOFD1350">err:FOFD1350</a>:
31     * Raised when a component specifier within a picture string refers to a
32     * component that is not available in the value being formatted.
33     */
34    public static final int COMPONENT_NOT_AVAILABLE = 1350;
35  
36    /**
37     * the serial version UID.
38     */
39    private static final long serialVersionUID = 1L;
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 FormatDateTimeFunctionException(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 FormatDateTimeFunctionException(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 FormatDateTimeFunctionException(int code, Throwable cause) {
79      super(IErrorCode.of(PREFIX, code), cause);
80    }
81  }