All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ionic.sdk.error.ServerException Maven / Gradle / Ivy

Go to download

The Ionic Java SDK provides an easy-to-use interface to the Ionic Platform.

There is a newer version: 2.9.0
Show newest version
package com.ionic.sdk.error;

import com.ionic.sdk.agent.request.base.AgentResponseBase;

/**
 * An Exception class for representing Ionic server-side errors.
 * When an SDK call communicates with an Ionic server, it is possible that the
 * server incurs an error, rejects the data it receives, etc.  In that case, the SDK
 * throws a ServerException in order to indicate both the SDK-specific error data as
 * well as any server-specific error data.  The server-specific error data can be
 * helpful in determining why the communication failed.
 *
 * @deprecated Please migrate usages to the drop-in replacement class {@link IonicServerException}.
 */
@Deprecated
public class ServerException extends SdkException {

    /**
     * The HTTP response code.
     */
    private final int httpResponseCode;

    /**
     * The internal server error code.
     */
    private final int serverErrorCode;

    /**
     * The internal server error message.
     */
    private final String serverErrorMessage;

    /**
     * The internal server error data JSON.
     */
    private final String serverErrorDataJson;

    /**
     * The conversation ID generated by the client for use in the server request.
     */
    private final String conversationId;

    /**
     * The Ionic representation of the server response (if any).
     */
    private final AgentResponseBase response;

    /**
     * Initializes the exception with an SDK error code.
     *
     * @param errorCode the SDK error code
     */
    public ServerException(final int errorCode) {
        this(errorCode, SdkError.getErrorString(errorCode), 0, 0, null, null, null, null);
    }

    /**
     * Initializes the exception with an SDK error code.
     *
     * @param errorCode the SDK error code
     * @param message   the text description of the error
     */
    public ServerException(final int errorCode, final String message) {
        this(errorCode, message, 0, 0, null, null, null, null);
    }

    /**
     * Initializes the exception with a message.
     *
     * @param message   the text description of the error
     */
    public ServerException(final String message) {
        this(-1, message, 0, 0, null, null, null, null);
    }

    /**
     * Initializes the exception with an SDK error code.
     *
     * @param errorCode           the SDK error code
     * @param httpResponseCode    the HTTP response code
     * @param serverErrorCode     the internal server error code
     * @param serverErrorMessage  the internal server error message
     * @param serverErrorDataJson the internal server error data JSON
     * @param conversationId      the conversation ID generated by the client for use in the server request
     */
    public ServerException(final int errorCode, final int httpResponseCode,
                           final int serverErrorCode, final String serverErrorMessage,
                           final String serverErrorDataJson, final String conversationId) {
        super(errorCode, SdkError.getErrorString(errorCode));
        this.httpResponseCode = httpResponseCode;
        this.serverErrorCode = serverErrorCode;
        this.serverErrorMessage = serverErrorMessage;
        this.serverErrorDataJson = serverErrorDataJson;
        this.conversationId = conversationId;
        this.response = null;
    }

    /**
     * Initializes the exception with an SDK error code.
     *
     * @param errorCode           the SDK error code
     * @param message             the text description of the error
     * @param httpResponseCode    the HTTP response code
     * @param serverErrorCode     the internal server error code
     * @param serverErrorMessage  the internal server error message
     * @param serverErrorDataJson the internal server error data JSON
     * @param conversationId      the conversation ID generated by the client for use in the server request
     */
    public ServerException(final int errorCode, final String message, final int httpResponseCode,
                           final int serverErrorCode, final String serverErrorMessage,
                           final String serverErrorDataJson, final String conversationId) {
        super(errorCode, message);
        this.httpResponseCode = httpResponseCode;
        this.serverErrorCode = serverErrorCode;
        this.serverErrorMessage = serverErrorMessage;
        this.serverErrorDataJson = serverErrorDataJson;
        this.conversationId = conversationId;
        this.response = null;
    }

    /**
     * Initializes the exception with an SDK error code.
     *
     * @param errorCode           the SDK error code
     * @param message             the text description of the error
     * @param httpResponseCode    the HTTP response code
     * @param serverErrorCode     the internal server error code
     * @param serverErrorMessage  the internal server error message
     * @param serverErrorDataJson the internal server error data JSON
     * @param conversationId      the conversation ID generated by the client for use in the server request
     * @param response            the Ionic representation of the server response
     */
    @SuppressWarnings({"checkstyle:parameternumber"})
    public ServerException(final int errorCode, final String message, final int httpResponseCode,
                           final int serverErrorCode, final String serverErrorMessage,
                           final String serverErrorDataJson, final String conversationId,
                           final AgentResponseBase response) {
        super(errorCode, message);
        this.httpResponseCode = httpResponseCode;
        this.serverErrorCode = serverErrorCode;
        this.serverErrorMessage = serverErrorMessage;
        this.serverErrorDataJson = serverErrorDataJson;
        this.conversationId = conversationId;
        this.response = response;
    }

    /**
     * @return the HTTP response code
     */
    public final int getHttpResponseCode() {
        return httpResponseCode;
    }

    /**
     * @return the internal server error code
     */
    public final int getServerErrorCode() {
        return serverErrorCode;
    }

    /**
     * @return the internal server error message
     */
    public final String getServerErrorMessage() {
        return serverErrorMessage;
    }

    /**
     * @return the internal server error data JSON
     */
    public final String getServerErrorDataJson() {
        return serverErrorDataJson;
    }

    /**
     * @return the conversation ID generated by the client for use in the server request
     */
    public final String getConversationId() {
        return conversationId;
    }

    /**
     * @return the Ionic representation of the server response
     */
    public final AgentResponseBase getResponse() {
        return response;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy