]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.eclipse.swt.win32.win32.x86_64/src/org/eclipse/swt/SWTException.java
Work around SWT 4.13 - 4.18 Win32 DnD bug 567422
[simantics/platform.git] / bundles / org.eclipse.swt.win32.win32.x86_64 / src / org / eclipse / swt / SWTException.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 runtime exception is thrown whenever a recoverable 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  * exception that caused the problem (if this information is
22  * available (i.e. it may be null)).
23  * <p>
24  * SWTExceptions are thrown when something fails internally,
25  * but SWT is left in a known stable state (eg. a widget call
26  * was made from a non-u/i thread, or there is failure while
27  * reading an Image because the source file was corrupt).
28  * </p>
29  *
30  * @see SWTError
31  * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
32  */
33
34 public class SWTException extends RuntimeException {
35         /**
36          * The SWT error code, one of SWT.ERROR_*.
37          */
38         public int code;
39
40         /**
41          * The underlying throwable that caused the problem,
42          * or null if this information is not available.
43          */
44         public Throwable throwable;
45
46         static final long serialVersionUID = 3257282552304842547L;
47
48 /**
49  * Constructs a new instance of this class with its
50  * stack trace filled in. The error code is set to an
51  * unspecified value.
52  */
53 public SWTException () {
54         this (SWT.ERROR_UNSPECIFIED);
55 }
56
57 /**
58  * Constructs a new instance of this class with its
59  * stack trace and message filled in. The error code is
60  * set to an unspecified value.  Specifying <code>null</code>
61  * as the message is equivalent to specifying an empty string.
62  *
63  * @param message the detail message for the exception
64  */
65 public SWTException (String message) {
66         this (SWT.ERROR_UNSPECIFIED, message);
67 }
68
69 /**
70  * Constructs a new instance of this class with its
71  * stack trace and error code filled in.
72  *
73  * @param code the SWT error code
74  */
75 public SWTException (int code) {
76         this (code, SWT.findErrorText (code));
77 }
78
79 /**
80  * Constructs a new instance of this class with its
81  * stack trace, error code and message filled in.
82  * Specifying <code>null</code> as the message is
83  * equivalent to specifying an empty string.
84  *
85  * @param code the SWT error code
86  * @param message the detail message for the exception
87  */
88 public SWTException (int code, String message) {
89         super (message);
90         this.code = code;
91 }
92
93 /**
94  * Returns the underlying throwable that caused the problem,
95  * or null if this information is not available.
96  * <p>
97  * NOTE: This method overrides Throwable.getCause() that was
98  * added to JDK1.4. It is necessary to override this method
99  * in order for inherited printStackTrace() methods to work.
100  * </p>
101  * @return the underlying throwable
102  *
103  * @since 3.1
104  */
105 @Override
106 public Throwable getCause() {
107         return throwable;
108 }
109
110 /**
111  *  Returns the string describing this SWTException object.
112  *  <p>
113  *  It is combined with the message string of the Throwable
114  *  which caused this SWTException (if this information is available).
115  *  </p>
116  *  @return the error message string of this SWTException object
117  */
118 @Override
119 public String getMessage () {
120         if (throwable == null) return super.getMessage ();
121         return super.getMessage () + " (" + throwable.toString () + ")"; //$NON-NLS-1$ //$NON-NLS-2$
122 }
123
124 /**
125  * Outputs a printable representation of this exception's
126  * stack trace on the standard error stream.
127  * <p>
128  * Note: printStackTrace(PrintStream) and printStackTrace(PrintWriter)
129  * are not provided in order to maintain compatibility with CLDC.
130  * </p>
131  */
132 @Override
133 public void printStackTrace () {
134         super.printStackTrace ();
135 }
136
137 }
138
139