illab.nabal.exception.NetworkException.java Source code

Java tutorial

Introduction

Here is the source code for illab.nabal.exception.NetworkException.java

Source

/*
 * Copyright (C) 2013-2014 Tan Jung
 *
 * 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 illab.nabal.exception;

import org.json.JSONObject;

/**
 * Exception class for handling network-related errors.
 * 
 * @version 1.0, 02/10/14
 * @author <a href="mailto:tanito.jung@gmail.com">Tan Jung</a>
 */
public class NetworkException extends Exception {
    private static final long serialVersionUID = 412025781788928837L;

    private int httpStatusCode;

    private String extraMessage;

    private String responseString;

    private JSONObject responseJson;

    public NetworkException() {
        super();
    }

    public NetworkException(String message) {
        super(message);
    }

    public NetworkException(String message, String extraMessage) {
        super(message);
        this.extraMessage = extraMessage;
    }

    public NetworkException(int httpStatusCode, String message, String extraMessage) {
        super(message);
        this.httpStatusCode = httpStatusCode;
        this.extraMessage = extraMessage;
    }

    public NetworkException(Throwable cause) {
        super(cause);
    }

    public NetworkException(String message, Throwable cause) {
        super(message, cause);
    }

    public NetworkException(String message, String extraMessage, Throwable cause) {
        super(message, cause);
        this.extraMessage = extraMessage;
    }

    public NetworkException(int httpStatusCode, String message, String extraMessage, Throwable cause) {
        super(message, cause);
        this.httpStatusCode = httpStatusCode;
        this.extraMessage = extraMessage;
    }

    public int getHttpStatusCode() {
        return httpStatusCode;
    }

    public String getExtraMessage() {
        return extraMessage;
    }

    public String getResponseString() {
        return responseString;
    }

    public NetworkException setResponseString(String responseString) {
        this.responseString = responseString;
        return this;
    }

    public JSONObject getResponseJson() {
        return responseJson;
    }

    public NetworkException setResponseJson(JSONObject responseJson) {
        this.responseJson = responseJson;
        return this;
    }

}