]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.eclipse.swt.win32.win32.x86_64/src/org/eclipse/swt/SWTError.java
Remove invalid SHA-256-Digests
[simantics/platform.git] / bundles / org.eclipse.swt.win32.win32.x86_64 / src / org / eclipse / swt / SWTError.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2011 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *******************************************************************************/
14 package org.eclipse.swt;
15
16 /**
17  * This error is thrown whenever an unrecoverable error
18  * occurs internally in SWT. The message text and error code
19  * provide a further description of the problem. The exception
20  * has a <code>throwable</code> field which holds the underlying
21  * throwable that caused the problem (if this information is
22  * available (i.e. it may be null)).
23  * <p>
24  * SWTErrors are thrown when something fails internally which
25  * either leaves SWT in an unknown state (eg. the o/s call to
26  * remove an item from a list returns an error code) or when SWT
27  * is left in a known-to-be-unrecoverable state (eg. it runs out
28  * of callback resources). SWTErrors should not occur in typical
29  * programs, although "high reliability" applications should
30  * still catch them.
31  * </p><p>
32  * This class also provides support methods used by SWT to match
33  * error codes to the appropriate exception class (SWTError,
34  * SWTException, or IllegalArgumentException) and to provide
35  * human readable strings for SWT error codes.
36  * </p>
37  *
38  * @see SWTException
39  * @see SWT#error(int)
40  * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
41  */
42
43 public class SWTError extends Error {
44         /**
45          * The SWT error code, one of SWT.ERROR_*.
46          */
47         public int code;
48
49         /**
50          * The underlying throwable that caused the problem,
51          * or null if this information is not available.
52          */
53         public Throwable throwable;
54
55         static final long serialVersionUID = 3833467327105808433L;
56
57 /**
58  * Constructs a new instance of this class with its
59  * stack trace filled in. The error code is set to an
60  * unspecified value.
61  */
62 public SWTError () {
63         this (SWT.ERROR_UNSPECIFIED);
64 }
65
66 /**
67  * Constructs a new instance of this class with its
68  * stack trace and message filled in. The error code is
69  * set to an unspecified value.  Specifying <code>null</code>
70  * as the message is equivalent to specifying an empty string.
71  *
72  * @param message the detail message for the exception
73  */
74 public SWTError (String message) {
75         this (SWT.ERROR_UNSPECIFIED, message);
76 }
77
78 /**
79  * Constructs a new instance of this class with its
80  * stack trace and error code filled in.
81  *
82  * @param code the SWT error code
83  */
84 public SWTError (int code) {
85         this (code, SWT.findErrorText (code));
86 }
87
88 /**
89  * Constructs a new instance of this class with its
90  * stack trace, error code and message filled in.
91  * Specifying <code>null</code> as the message is
92  * equivalent to specifying an empty string.
93  *
94  * @param code the SWT error code
95  * @param message the detail message for the exception
96  */
97 public SWTError (int code, String message) {
98         super (message);
99         this.code = code;
100 }
101
102 /**
103  * Returns the underlying throwable that caused the problem,
104  * or null if this information is not available.
105  * <p>
106  * NOTE: This method overrides Throwable.getCause() that was
107  * added to JDK1.4. It is necessary to override this method
108  * in order for inherited printStackTrace() methods to work.
109  * </p>
110  * @return the underlying throwable
111  *
112  * @since 3.1
113  */
114 @Override
115 public Throwable getCause() {
116         return throwable;
117 }
118
119 /**
120  *  Returns the string describing this SWTError object.
121  *  <p>
122  *  It is combined with the message string of the Throwable
123  *  which caused this SWTError (if this information is available).
124  *  </p>
125  *  @return the error message string of this SWTError object
126  */
127 @Override
128 public String getMessage () {
129         if (throwable == null) return super.getMessage ();
130         return super.getMessage () + " (" + throwable.toString () + ")"; //$NON-NLS-1$ //$NON-NLS-2$
131 }
132
133 /**
134  * Outputs a printable representation of this error's
135  * stack trace on the standard error stream.
136  * <p>
137  * Note: printStackTrace(PrintStream) and printStackTrace(PrintWriter)
138  * are not provided in order to maintain compatibility with CLDC.
139  * </p>
140  */
141 @Override
142 public void printStackTrace () {
143         super.printStackTrace ();
144 }
145
146 }