KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > error > RequestExceptionReporterImpl


1 // Copyright 2004, 2005 The Apache Software Foundation
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15 package org.apache.tapestry.error;
16
17 import org.apache.commons.logging.Log;
18 import org.apache.tapestry.util.exception.ExceptionAnalyzer;
19 import org.apache.tapestry.web.WebRequest;
20 import org.apache.tapestry.web.WebSession;
21
22 /**
23  * @author Howard M. Lewis Ship
24  * @since 4.0
25  */

26 public class RequestExceptionReporterImpl implements RequestExceptionReporter
27 {
28     private Log _log;
29
30     private WebRequest _request;
31
32     public void setLog(Log log)
33     {
34         _log = log;
35     }
36
37     public void setRequest(WebRequest request)
38     {
39         _request = request;
40     }
41
42     public void reportRequestException(String JavaDoc message, Throwable JavaDoc cause)
43     {
44         _log.warn(message, cause);
45
46         System.err.println("\n\n**********************************************************\n\n");
47
48         System.err.println(message);
49
50         System.err.println("\n");
51
52         WebSession session = _request.getSession(false);
53
54         if (session != null)
55             System.err.println(" Session id : " + session.getId());
56
57         System.err.println("\nExceptions:\n");
58
59         new ExceptionAnalyzer().reportException(cause, System.err);
60
61         System.err.println("\n**********************************************************\n");
62     }
63
64 }
Popular Tags