KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > google > gwt > junit > client > impl > ExceptionWrapper


1 /*
2  * Copyright 2006 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.core.client.GWT;
19 import com.google.gwt.user.client.rpc.IsSerializable;
20
21 /**
22  * A helper class for converting a generic {@link Throwable} into an Object that
23  * can be serialized for RPC.
24  */

25 public final class ExceptionWrapper implements IsSerializable {
26
27   /**
28    * Corresponds to {@link Throwable#getCause()}.
29    */

30   public ExceptionWrapper cause;
31
32   /**
33    * Corresponds to {@link Throwable#getMessage()}.
34    */

35   public String JavaDoc message;
36
37   /**
38    * Corresponds to {@link Throwable#getStackTrace()}.
39    */

40   public StackTraceWrapper[] stackTrace;
41
42   /**
43    * The run-time type of the exception.
44    */

45   public String JavaDoc typeName;
46
47   /**
48    * Creates an empty {@link ExceptionWrapper}.
49    */

50   public ExceptionWrapper() {
51   }
52
53   /**
54    * Creates an {@link ExceptionWrapper} around an existing {@link Throwable}.
55    *
56    * @param e the {@link Throwable} to wrap.
57    */

58   public ExceptionWrapper(Throwable JavaDoc e) {
59     typeName = GWT.getTypeName(e);
60     message = e.getMessage();
61     stackTrace = StackTraceWrapper.wrapStackTrace(e.getStackTrace());
62     Throwable JavaDoc ecause = e.getCause();
63     if (ecause != null) {
64       cause = new ExceptionWrapper(ecause);
65     }
66   }
67
68 }
69
Popular Tags