Debian Codegraph @

rhino/src/org/mozilla/javascript/WrappedException.java

raw symbols SCIP
1 /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 package org.mozilla.javascript;
8
9 /**
10 * A wrapper for runtime exceptions.
11 *
12 * Used by the JavaScript runtime to wrap and propagate exceptions that occur
13 * during runtime.
14 *
15 * @author Norris Boyd
16 */
17 public class WrappedException extends EvaluatorException
18 {
19 static final long serialVersionUID = -1551979216966520648L;
20
21 /**
22 * @see Context#throwAsScriptRuntimeEx(Throwable e)
23 */
24 public WrappedException(Throwable exception)
25 {
26 super("Wrapped "+exception.toString());
27 this.exception = exception;
28 Kit.initCause(this, exception);
29
30 int[] linep = { 0 };
31 String sourceName = Context.getSourcePositionFromStack(linep);
32 int lineNumber = linep[0];
33 if (sourceName != null) {
34 initSourceName(sourceName);
35 }
36 if (lineNumber != 0) {
37 initLineNumber(lineNumber);
38 }
39 }
40
41 /**
42 * Get the wrapped exception.
43 *
44 * @return the exception that was presented as a argument to the
45 * constructor when this object was created
46 */
47 public Throwable getWrappedException()
48 {
49 return exception;
50 }
51
52 /**
53 * @deprecated Use {@link #getWrappedException()} instead.
54 */
55 @Deprecated
56 public Object unwrap()
57 {
58 return getWrappedException();
59 }
60
61 private Throwable exception;
62 }