Mercurial > projects > dwt2
comparison org.eclipse.equinox.common/src/org/eclipse/core/runtime/CoreException.d @ 105:bbe49769ec18
...
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 08 Nov 2009 12:42:30 +0100 |
parents | 735224fcc45f |
children |
comparison
equal
deleted
inserted
replaced
104:88652073d1c2 | 105:bbe49769ec18 |
---|---|
1 /******************************************************************************* | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2006 IBM Corporation and others. | 2 * Copyright (c) 2000, 2008 IBM Corporation and others. |
3 * All rights reserved. This program and the accompanying materials | 3 * All rights reserved. This program and the accompanying materials |
4 * are made available under the terms of the Eclipse Public License v1.0 | 4 * are made available under the terms of the Eclipse Public License v1.0 |
5 * which accompanies this distribution, and is available at | 5 * which accompanies this distribution, and is available at |
6 * http://www.eclipse.org/legal/epl-v10.html | 6 * http://www.eclipse.org/legal/epl-v10.html |
7 * | 7 * |
8 * Contributors: | 8 * Contributors: |
9 * IBM Corporation - initial API and implementation | 9 * IBM Corporation - initial API and implementation |
10 * Port to the D programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
12 *******************************************************************************/ | 10 *******************************************************************************/ |
13 module org.eclipse.core.runtime.CoreException; | 11 // Port to the D programming language: |
14 | 12 // Frank Benoit <benoit@tionex.de> |
15 import org.eclipse.core.runtime.IStatus; | 13 module org.eclipse.core.runtimeCoreException; |
16 | |
17 // import java.io.PrintStream; | |
18 // import java.io.PrintWriter; | |
19 | 14 |
20 import java.lang.all; | 15 import java.lang.all; |
16 | |
17 import org.eclipse.core.runtimeStatus; // packageimport | |
18 import org.eclipse.core.runtimeIStatus; // packageimport | |
19 | |
20 import java.io.PrintStream; | |
21 import java.io.PrintWriter; | |
22 | |
23 import org.eclipse.core.internal.runtime.PrintStackUtil; | |
21 | 24 |
22 /** | 25 /** |
23 * A checked exception representing a failure. | 26 * A checked exception representing a failure. |
24 * <p> | 27 * <p> |
25 * Core exceptions contain a status object describing the | 28 * Core exceptions contain a status object describing the |
26 * cause of the exception. | 29 * cause of the exception. |
27 * </p><p> | 30 * </p><p> |
28 * This class can be used without OSGi running. | 31 * This class can be used without OSGi running. |
29 * </p> | 32 * </p> |
30 * @see IStatus | 33 * @see IStatus |
32 public class CoreException : Exception { | 35 public class CoreException : Exception { |
33 | 36 |
34 /** | 37 /** |
35 * All serializable objects should have a stable serialVersionUID | 38 * All serializable objects should have a stable serialVersionUID |
36 */ | 39 */ |
37 private static const long serialVersionUID = 1L; | 40 private static final long serialVersionUID = 1L; |
38 | 41 |
39 /** Status object. */ | 42 /** Status object. */ |
40 private IStatus status; | 43 private IStatus status; |
41 | 44 |
42 /** | 45 /** |
50 this.status = status; | 53 this.status = status; |
51 } | 54 } |
52 | 55 |
53 /** | 56 /** |
54 * Returns the cause of this exception, or <code>null</code> if none. | 57 * Returns the cause of this exception, or <code>null</code> if none. |
55 * | 58 * |
56 * @return the cause for this exception | 59 * @return the cause for this exception |
57 * @since 3.4 | 60 * @since 3.4 |
58 */ | 61 */ |
59 public Exception getCause() { | 62 public Throwable getCause() { |
60 return status.getException(); | 63 return status.getException(); |
61 } | 64 } |
62 | 65 |
63 /** | 66 /** |
64 * Returns the status object for this exception. | 67 * Returns the status object for this exception. |
81 * Prints a stack trace out for the exception, and | 84 * Prints a stack trace out for the exception, and |
82 * any nested exception that it may have embedded in | 85 * any nested exception that it may have embedded in |
83 * its Status object. | 86 * its Status object. |
84 */ | 87 */ |
85 public void printStackTrace() { | 88 public void printStackTrace() { |
86 // printStackTrace(System.err); | 89 printStackTrace(System.err); |
87 getDwtLogger.error( __FILE__, __LINE__, "Exception in File {}({}): {}", this.file, this.line, this.msg ); | 90 } |
88 foreach( msg; this.info ){ | 91 |
89 getDwtLogger.error( __FILE__, __LINE__, " trc: {}", msg ); | 92 /** |
90 } | 93 * Prints a stack trace out for the exception, and |
91 if (status.getException() !is null) { | 94 * any nested exception that it may have embedded in |
92 getDwtLogger.error( __FILE__, __LINE__, "{}[{}]: ", this.classinfo.name, status.getCode() ); //$NON-NLS-1$ //$NON-NLS-2$ | 95 * its Status object. |
93 // status.getException().printStackTrace(); | 96 * |
94 auto e = status.getException(); | 97 * @param output the stream to write to |
95 getDwtLogger.error( __FILE__, __LINE__, "Exception in File {}({}): {}", e.file, e.line, e.msg ); | 98 */ |
96 foreach( msg; e.info ){ | 99 public void printStackTrace(PrintStream output) { |
97 getDwtLogger.error( __FILE__, __LINE__, " trc: {}", msg ); | 100 synchronized (output) { |
98 } | 101 super.printStackTrace(output); |
102 PrintStackUtil.printChildren(status, output); | |
99 } | 103 } |
100 } | 104 } |
101 | 105 |
102 //FIXME | 106 /** |
103 // /** | 107 * Prints a stack trace out for the exception, and |
104 // * Prints a stack trace out for the exception, and | 108 * any nested exception that it may have embedded in |
105 // * any nested exception that it may have embedded in | 109 * its Status object. |
106 // * its Status object. | 110 * |
107 // * | 111 * @param output the stream to write to |
108 // * @param output the stream to write to | 112 */ |
109 // */ | 113 public void printStackTrace(PrintWriter output) { |
110 // public void printStackTrace(PrintStream output) { | 114 synchronized (output) { |
111 // synchronized (output) { | 115 super.printStackTrace(output); |
112 // super.printStackTrace(output); | 116 PrintStackUtil.printChildren(status, output); |
113 // if (status.getException() !is null) { | 117 } |
114 // output.print(getClass().getName() + "[" + status.getCode() + "]: "); //$NON-NLS-1$ //$NON-NLS-2$ | 118 } |
115 // status.getException().printStackTrace(output); | |
116 // } | |
117 // } | |
118 // } | |
119 // | |
120 // /** | |
121 // * Prints a stack trace out for the exception, and | |
122 // * any nested exception that it may have embedded in | |
123 // * its Status object. | |
124 // * | |
125 // * @param output the stream to write to | |
126 // */ | |
127 // public void printStackTrace(PrintWriter output) { | |
128 // synchronized (output) { | |
129 // super.printStackTrace(output); | |
130 // if (status.getException() !is null) { | |
131 // output.print(getClass().getName() + "[" + status.getCode() + "]: "); //$NON-NLS-1$ //$NON-NLS-2$ | |
132 // status.getException().printStackTrace(output); | |
133 // } | |
134 // } | |
135 // } | |
136 | |
137 } | 119 } |