View Javadoc
1   /*
2    * GordianKnot: Security Suite
3    * Copyright 2012-2026. Tony Washer
4    *
5    * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6    * use this file except in compliance with the License.  You may obtain a copy
7    * of the License at
8    *
9    *   http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
14   * License for the specific language governing permissions and limitations under
15   * the License.
16   */
17  package io.github.tonywasher.joceanus.gordianknot.api.base;
18  
19  import java.io.Serial;
20  
21  /**
22   * Exception extension class.
23   */
24  public abstract class GordianException
25          extends Exception {
26      /**
27       * Required serialisation field.
28       */
29      @Serial
30      private static final long serialVersionUID = -8980967515725110116L;
31  
32      /**
33       * The associated object.
34       */
35      private final transient Object theObject;
36  
37      /**
38       * Create a wrapped Exception object based on an underlying exception.
39       *
40       * @param c the underlying exception
41       */
42      protected GordianException(final Throwable c) {
43          super(c);
44          theObject = null;
45      }
46  
47      /**
48       * Create a new Exception object based on a string and class.
49       *
50       * @param s the description of the exception
51       */
52      protected GordianException(final String s) {
53          super(s);
54          theObject = null;
55          fillInStackTrace();
56      }
57  
58      /**
59       * Create a new Exception object based on a string and an underlying exception.
60       *
61       * @param s the description of the exception
62       * @param c the underlying exception
63       */
64      protected GordianException(final String s,
65                                 final Throwable c) {
66          super(s, c);
67          theObject = null;
68      }
69  
70      /**
71       * Create a new Exception object based on a string and an object.
72       *
73       * @param o the associated object
74       * @param s the description of the exception
75       */
76      protected GordianException(final Object o,
77                                 final String s) {
78          super(s);
79          theObject = o;
80          fillInStackTrace();
81      }
82  
83      /**
84       * Create a new Exception object based on a string, an object and an underlying exception.
85       *
86       * @param o the associated object
87       * @param s the description of the exception
88       * @param c the underlying exception
89       */
90      protected GordianException(final Object o,
91                                 final String s,
92                                 final Throwable c) {
93          super(s, c);
94          theObject = o;
95      }
96  
97      /**
98       * Get the associated object.
99       *
100      * @return the associated object
101      */
102     public Object getObject() {
103         return theObject;
104     }
105 }