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.junit.client.impl;
17:
18: import com.google.gwt.user.client.rpc.IsSerializable;
19:
20: /**
21: * A helper class for converting a generic {@link Throwable} into an Object that
22: * can be serialized for RPC.
23: */
24: public final class ExceptionWrapper implements IsSerializable {
25:
26: /**
27: * Corresponds to {@link Throwable#getCause()}.
28: */
29: public ExceptionWrapper cause;
30:
31: /**
32: * Corresponds to {@link Throwable#getMessage()}.
33: */
34: public String message;
35:
36: /**
37: * Corresponds to {@link Throwable#getStackTrace()}.
38: */
39: public StackTraceWrapper[] stackTrace;
40:
41: /**
42: * The run-time type of the exception.
43: */
44: public String typeName;
45:
46: /**
47: * Creates an empty {@link ExceptionWrapper}.
48: */
49: public ExceptionWrapper() {
50: }
51:
52: /**
53: * Creates an {@link ExceptionWrapper} around an existing {@link Throwable}.
54: *
55: * @param e the {@link Throwable} to wrap.
56: */
57: public ExceptionWrapper(Throwable e) {
58: typeName = e.getClass().getName();
59: message = e.getMessage();
60: stackTrace = StackTraceWrapper
61: .wrapStackTrace(e.getStackTrace());
62: Throwable ecause = e.getCause();
63: if (ecause != null) {
64: cause = new ExceptionWrapper(ecause);
65: }
66: }
67:
68: }
|