de.aflx.sardine.impl.SardineException.java Source code

Java tutorial

Introduction

Here is the source code for de.aflx.sardine.impl.SardineException.java

Source

/*
 * Copyright 2009-2011 Jon Stevens et al.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package de.aflx.sardine.impl;

import org.apache.http.client.HttpResponseException;

/**
 * Specialized type of exception for Sardine so
 * that it is easy to get the error information from it.
 *
 * @author jonstevens
 * @version $Id: SardineException.java 309 2011-11-18 09:27:52Z dkocher@sudo.ch $
 */
public class SardineException extends HttpResponseException {
    private static final long serialVersionUID = -3900043433469104564L;

    private String responsePhrase;

    /**
     * @param msg         Custom description of failure
     * @param statusCode    Error code returned by server
     * @param responsePhrase Response phrase following the error code
     */
    public SardineException(String msg, int statusCode, String responsePhrase) {
        super(statusCode, msg);
        this.responsePhrase = responsePhrase;
    }

    /**
     * The response phrase returned by the server.
     *
     * @return Null if not known.
     */
    public String getResponsePhrase() {
        return this.responsePhrase;
    }

    @Override
    public String toString() {
        return super.toString() + " (" + this.getStatusCode() + " " + responsePhrase + ")";
    }
}