KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lutris > util > ExceptionUtils


1
2 /*
3  * Enhydra Java Application Server Project
4  *
5  * The contents of this file are subject to the Enhydra Public License
6  * Version 1.1 (the "License"); you may not use this file except in
7  * compliance with the License. You may obtain a copy of the License on
8  * the Enhydra web site ( http://www.enhydra.org/ ).
9  *
10  * Software distributed under the License is distributed on an "AS IS"
11  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
12  * the License for the specific terms governing rights and limitations
13  * under the License.
14  *
15  * The Initial Developer of the Enhydra Application Server is Lutris
16  * Technologies, Inc. The Enhydra Application Server and portions created
17  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
18  * All Rights Reserved.
19  *
20  * Contributor(s):
21  *
22  * $Id: ExceptionUtils.java,v 1.2 2005/03/24 10:51:25 slobodan Exp $
23  */

24
25 package com.lutris.util;
26
27 import java.io.PrintWriter JavaDoc;
28 import java.io.StringWriter JavaDoc;
29
30 /**
31  * A collection of static methods that deal with Exceptions.
32  *
33  * @see java.lang.Exception;
34  * @author Andy John
35  */

36 public class ExceptionUtils {
37
38     /**
39      * Do not instantiate objects of this class. Use the static methods.
40      */

41     private ExceptionUtils() {
42     }
43
44
45     /**
46      * Returns a text description of the Exception. This uses both the
47      * <CODE>toString()</CODE> method and the <CODE>printStackTrace()</CODE>
48      * method.
49      *
50      * @param e The Exception to return a description of.
51      * @return A full description of the Exception.
52      */

53     public static String JavaDoc describeException(Exception JavaDoc e) {
54         StringWriter JavaDoc sw = new StringWriter JavaDoc();
55         PrintWriter JavaDoc pw = new PrintWriter JavaDoc(sw);
56         pw.println(e);
57         e.printStackTrace(pw);
58         return sw.toString();
59     }
60 }
61
62
Popular Tags