org.eclipse.mylyn.github.internal.GitHubServiceException.java Source code

Java tutorial

Introduction

Here is the source code for org.eclipse.mylyn.github.internal.GitHubServiceException.java

Source

/*
 * Copyright 2009 Christian Trutz 
 * 
 * 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 org.eclipse.mylyn.github.internal;

import org.apache.commons.httpclient.StatusLine;

/**
 * Exception generated by the GitHubService
 */
public class GitHubServiceException extends Exception {

    /**
     * Auto generated serialVersionUID
     */
    private static final long serialVersionUID = -6287902058352190022L;

    private int httpStatusCode = Integer.MIN_VALUE;

    /**
     * Constructor for the GitHubServiceException
     * 
     * @param exception
     *            - Exception to wrap around
     */
    protected GitHubServiceException(final Exception exception) {
        super(exception);
    }

    protected GitHubServiceException(String message, Throwable cause) {
        super(message, cause);
    }

    protected GitHubServiceException(String message) {
        super(message);
    }

    protected GitHubServiceException(StatusLine statusLine) {
        this(String.format("HTTP %s: %s", statusLine.getStatusCode(), statusLine.getReasonPhrase()));
        httpStatusCode = statusLine.getStatusCode();
    }

    /**
     * the HTTP status code, or -1 if unknown or not applicable.
     */
    public int getHttpStatusCode() {
        return httpStatusCode;
    }
}