1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 * 19 */ 20 package org.apache.mina.http; 21 22 import org.apache.mina.http.api.HttpStatus; 23 24 /** 25 * 26 * @author <a href="http://mina.apache.org">Apache MINA Project</a> 27 */ 28 @SuppressWarnings("serial") 29 public class HttpException extends RuntimeException { 30 private final int statusCode; 31 32 /** 33 * Creates a new HttpException instance 34 * 35 * @param statusCode The associated status code 36 */ 37 public HttpException(int statusCode) { 38 this(statusCode, ""); 39 } 40 41 /** 42 * Creates a new HttpException instance 43 * 44 * @param statusCode The associated status code 45 */ 46 public HttpException(HttpStatus statusCode) { 47 this(statusCode, ""); 48 } 49 50 /** 51 * Creates a new HttpException instance 52 * 53 * @param statusCode The associated status code 54 * @param message The error message 55 */ 56 public HttpException(int statusCode, String message) { 57 super(message); 58 this.statusCode = statusCode; 59 } 60 61 /** 62 * Creates a new HttpException instance 63 * 64 * @param statusCode The associated status code 65 * @param message The error message 66 */ 67 public HttpException(HttpStatus statusCode, String message) { 68 super(message); 69 this.statusCode = statusCode.code(); 70 } 71 72 /** 73 * @return The statusCode 74 */ 75 public int getStatusCode() { 76 return statusCode; 77 } 78 }