KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mortbay > http > HttpException


1 // ========================================================================
2
// $Id: HttpException.java,v 1.5 2004/05/09 20:31:40 gregwilkins Exp $
3
// Copyright 1999-2004 Mort Bay Consulting Pty. Ltd.
4
// ------------------------------------------------------------------------
5
// Licensed under the Apache License, Version 2.0 (the "License");
6
// you may not use this file except in compliance with the License.
7
// You may obtain a copy of the License at
8
// http://www.apache.org/licenses/LICENSE-2.0
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

16 package org.mortbay.http;
17 import java.io.IOException JavaDoc;
18
19 import org.mortbay.util.TypeUtil;
20
21
22 /* ------------------------------------------------------------ */
23 /** Exception for known HTTP error status.
24  *
25  * @version $Revision: 1.5 $
26  * @author Greg Wilkins (gregw)
27  */

28 public class HttpException extends IOException JavaDoc
29 {
30     private int _code;
31
32     public int getCode()
33     {
34         return _code;
35     }
36     
37     public String JavaDoc getReason()
38     {
39         return (String JavaDoc)HttpResponse.__statusMsg.get(TypeUtil.newInteger(_code));
40     }
41     
42     public HttpException()
43     {
44         _code=HttpResponse.__400_Bad_Request ;
45     }
46     
47     public HttpException(int code)
48     {
49         _code=code;
50     }
51     
52     public HttpException(int code, String JavaDoc message)
53     {
54         super(message);
55         _code=code;
56     }
57
58     public String JavaDoc toString()
59     {
60         String JavaDoc message=getMessage();
61         String JavaDoc reason=getReason();
62         return "HttpException("+_code+","+reason+","+message+")";
63     }
64 }
65
66
Popular Tags