01: /*
02: * Copyright 2006 Google Inc.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License. You may obtain a copy of
06: * the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13: * License for the specific language governing permissions and limitations under
14: * the License.
15: */
16: package com.google.gwt.core.client;
17:
18: /**
19: * Any JavaScript exceptions occurring within JSNI methods are wrapped as this
20: * class when caught in Java code. The wrapping does not occur until the
21: * exception passes out of JSNI into Java. Before that, the thrown object
22: * remains a native JavaScript exception object, and can be caught in JSNI as
23: * normal.
24: */
25: public final class JavaScriptException extends RuntimeException {
26:
27: /**
28: * The original type name of the JavaScript exception this class wraps,
29: * initialized as <code>e.name</code>.
30: */
31: private final String name;
32:
33: /**
34: * The original description of the JavaScript exception this class wraps,
35: * initialized as <code>e.message</code>.
36: */
37: private final String description;
38:
39: /**
40: * @param name the original JavaScript type name of the exception
41: * @param description the original JavaScript message of the exception
42: */
43: public JavaScriptException(String name, String description) {
44: super ("JavaScript " + name + " exception: " + description);
45: this .name = name;
46: this .description = description;
47: }
48:
49: /**
50: * Useful for server-side instantiation.
51: *
52: * @param message the detail message.
53: */
54: protected JavaScriptException(String message) {
55: super (message);
56: this .name = null;
57: this .description = message;
58: }
59:
60: /**
61: * @return the original JavaScript message of the exception
62: */
63: public String getDescription() {
64: return description;
65: }
66:
67: /**
68: * @return the original JavaScript type name of the exception
69: */
70: public String getName() {
71: return name;
72: }
73:
74: }
|