Skip to content

Commit 892563d

Browse files
committed
parser: log exceptions
1 parent 6a0786f commit 892563d

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

plugins/org.eclipse.dltk.javascript.parser/src/org/eclipse/dltk/javascript/parser/JavaScriptParser.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,7 @@ protected Script parse(IModelElement element, JSTokenStream stream,
384384
}
385385
return script;
386386
} catch (Exception e) {
387-
if (DLTKCore.DEBUG)
388-
e.printStackTrace();
387+
JavaScriptParserPlugin.error(e);
389388
if (reporter != null) {
390389
reporter.reportProblem(new JSProblem(e));
391390
}

plugins/org.eclipse.dltk.javascript.parser/src/org/eclipse/dltk/javascript/parser/JavaScriptParserPlugin.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
*******************************************************************************/
1212
package org.eclipse.dltk.javascript.parser;
1313

14+
import org.eclipse.core.runtime.IStatus;
1415
import org.eclipse.core.runtime.Plugin;
16+
import org.eclipse.core.runtime.Status;
1517
import org.osgi.framework.BundleContext;
1618

1719
public class JavaScriptParserPlugin extends Plugin {
@@ -46,4 +48,35 @@ public static JavaScriptParserPlugin getDefault() {
4648
return plugin;
4749
}
4850

51+
/**
52+
* @since 5.0
53+
*/
54+
public static void error(String message) {
55+
error(message, null);
56+
}
57+
58+
/**
59+
* @since 5.0
60+
*/
61+
public static void error(Throwable e) {
62+
error(e.getLocalizedMessage(), e);
63+
}
64+
65+
/**
66+
* @since 5.0
67+
*/
68+
public static void error(String message, Throwable t) {
69+
final Plugin p = plugin;
70+
if (p != null) {
71+
p.getLog()
72+
.log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK,
73+
message, t));
74+
} else {
75+
System.err.println(message);
76+
if (t != null) {
77+
t.printStackTrace();
78+
}
79+
}
80+
}
81+
4982
}

0 commit comments

Comments
 (0)