001// *************************************************************************************************************************** 002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * 003// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * 004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * 005// * with the License. You may obtain a copy of the License at * 006// * * 007// * http://www.apache.org/licenses/LICENSE-2.0 * 008// * * 009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * 010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * 011// * specific language governing permissions and limitations under the License. * 012// *************************************************************************************************************************** 013package org.apache.juneau.utils; 014 015import java.net.*; 016import java.text.*; 017 018import org.apache.juneau.*; 019 020/** 021 * Generic exception thrown from the {@link PojoRest} class. 022 * 023 * <p> 024 * Typically, this is a user-error, such as trying to address a non-existent node in the tree. 025 * 026 * <p> 027 * The status code is an HTTP-equivalent code. It will be one of the following: 028 * <ul class='spaced-list'> 029 * <li> 030 * {@link HttpURLConnection#HTTP_BAD_REQUEST HTTP_BAD_REQUEST} 031 * - Attempting to do something impossible. 032 * <li> 033 * {@link HttpURLConnection#HTTP_NOT_FOUND HTTP_NOT_FOUND} 034 * - Attempting to access a non-existent node in the tree. 035 * <li> 036 * {@link HttpURLConnection#HTTP_FORBIDDEN HTTP_FORBIDDEN} 037 * - Attempting to overwrite the root object. 038 * </ul> 039 */ 040public final class PojoRestException extends FormattedRuntimeException { 041 042 private static final long serialVersionUID = 1L; 043 044 private int status; 045 046 /** 047 * Constructor. 048 * 049 * @param status The HTTP-equivalent status code. 050 * @param message The detailed message. 051 * @param args Optional {@link MessageFormat}-style arguments. 052 */ 053 public PojoRestException(int status, String message, Object...args) { 054 super(message, args); 055 this.status = status; 056 } 057 058 /** 059 * The HTTP-equivalent status code. 060 * 061 * <p> 062 * See above for details. 063 * 064 * @return The HTTP-equivalent status code. 065 */ 066 public int getStatus() { 067 return status; 068 } 069}