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   * FODT: Exceptions related to Date/Time/Duration errors.
13   */
14  public class DateTimeFunctionException
15      extends FunctionMetapathError {
16    @NonNull
17    private static final String PREFIX = "FODT";
18    /**
19     * <a href=
20     * "https://www.w3.org/TR/xpath-functions-31/#ERRFODT0001">err:FODT0001</a>:
21     * Raised when casting to date/time datatypes, or performing arithmetic with
22     * date/time values, if arithmetic overflow or underflow occurs.
23     */
24    public static final int DATE_TIME_OVERFLOW_UNDERFLOW_ERROR = 1;
25    /**
26     * <a href=
27     * "https://www.w3.org/TR/xpath-functions-31/#ERRFODT0002">err:FODT0002</a>:
28     * Raised when casting to duration datatypes, or performing arithmetic with
29     * duration values, if arithmetic overflow or underflow occurs.
30     */
31    public static final int DURATION_OVERFLOW_UNDERFLOW_ERROR = 2;
32    /**
33     * <a href=
34     * "https://www.w3.org/TR/xpath-functions-31/#ERRFODT0003">err:FODT0003</a>:
35     * Raised by adjust-date-to-timezone and related functions if the supplied
36     * timezone is invalid.
37     */
38    public static final int INVALID_TIME_ZONE_VALUE_ERROR = 3;
39  
40    /**
41     * the serial version UID.
42     */
43    private static final long serialVersionUID = 2L;
44  
45    /**
46     * Constructs a new exception with the provided {@code code}, {@code message},
47     * and no cause.
48     *
49     * @param code
50     *          the error code value
51     * @param message
52     *          the exception message
53     */
54    public DateTimeFunctionException(int code, String message) {
55      super(IErrorCode.of(PREFIX, code), message);
56    }
57  
58    /**
59     * Constructs a new exception with the provided {@code code}, {@code message},
60     * and {@code cause}.
61     *
62     * @param code
63     *          the error code value
64     * @param message
65     *          the exception message
66     * @param cause
67     *          the original exception cause
68     */
69    public DateTimeFunctionException(int code, String message, Throwable cause) {
70      super(IErrorCode.of(PREFIX, code), message, cause);
71    }
72  
73    /**
74     * Constructs a new exception with the provided {@code code}, no message, and
75     * the {@code cause}.
76     *
77     * @param code
78     *          the error code value
79     * @param cause
80     *          the original exception cause
81     */
82    public DateTimeFunctionException(int code, Throwable cause) {
83      super(IErrorCode.of(PREFIX, code), cause);
84    }
85  }