KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > slide > common > SlideException


1 /*
2  * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/SlideException.java,v 1.10 2004/07/28 09:38:11 ib Exp $
3  * $Revision: 1.10 $
4  * $Date: 2004/07/28 09:38:11 $
5  *
6  * ====================================================================
7  *
8  * Copyright 1999-2002 The Apache Software Foundation
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */

23
24 package org.apache.slide.common;
25
26 import java.io.PrintWriter JavaDoc;
27 import java.io.StringWriter JavaDoc;
28
29 import org.apache.slide.common.Domain;
30 import org.apache.slide.util.logger.Logger;
31
32
33 /**
34  * Exception supertype for all Slide components.
35  *
36  * @version $Revision: 1.10 $
37  */

38 public class SlideException extends Exception JavaDoc {
39
40     private static final String JavaDoc CHANNEL = "org.apache.slide.common.SlideException";
41     private static final int DEBUG = Logger.DEBUG;
42     private static Logger LOGGER = Domain.getLogger();
43
44
45     // ----------------------------------------------------------- Constructors
46

47
48     /**
49      * SlideException with logging.
50      *
51      * @param message Exception message
52      */

53     public SlideException(String JavaDoc message) {
54         this(message, true);
55     }
56
57
58     /**
59      * SlideException with or without logging.
60      *
61      * @param message Exception message
62      * @param showTrace Defines whether or not something is logged
63      */

64     public SlideException(String JavaDoc message, boolean showTrace) {
65         super(message);
66         if (showTrace) {
67             Domain.warn(message);
68         }
69
70       if (LOGGER.isEnabled(CHANNEL, DEBUG)) {
71             StringWriter JavaDoc sw = new StringWriter JavaDoc();
72             printStackTrace( new PrintWriter JavaDoc(sw, true) ); //autoFlush=true
73
LOGGER.log( sw.toString(), CHANNEL, DEBUG );
74       }
75     }
76
77 }
78
Popular Tags