001/* 002 * Licensed to DuraSpace under one or more contributor license agreements. 003 * See the NOTICE file distributed with this work for additional information 004 * regarding copyright ownership. 005 * 006 * DuraSpace licenses this file to you under the Apache License, 007 * Version 2.0 (the "License"); you may not use this file except in 008 * compliance with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.fcrepo.client; 019 020import java.net.URI; 021 022/** 023 * Represents a failure of the underlying HTTP client's interaction with fedora. 024 * 025 * @author Aaron Coburn 026 * @since January 8, 2015 027 */ 028public class FcrepoOperationFailedException extends Exception { 029 030 private final URI url; 031 private final int statusCode; 032 private final String statusText; 033 034 /** 035 * Create an FcrepoOperationFailedException 036 * 037 * @param url the requested url 038 * @param statusCode the HTTP response code 039 * @param statusText the response message 040 */ 041 public FcrepoOperationFailedException(final URI url, final int statusCode, final String statusText) { 042 super("HTTP operation failed invoking " + (url != null ? url.toString() : "[null]") + 043 " with statusCode: " + statusCode + " and message: " + statusText); 044 this.url = url; 045 this.statusCode = statusCode; 046 this.statusText = statusText; 047 } 048 049 /** 050 * Return the requested url 051 * 052 * @return the requested URL 053 */ 054 public URI getUrl() { 055 return url; 056 } 057 058 /** 059 * Get the status code 060 * 061 * @return the HTTP status code 062 */ 063 public int getStatusCode() { 064 return statusCode; 065 } 066 067 /** 068 * Get the status text 069 * 070 * @return the status text for the error 071 */ 072 public String getStatusText() { 073 return statusText; 074 } 075}