package be.iminds.jfed.gts_highlevel.controller;

import be.iminds.ilabt.jfed.lowlevel.api.RestApi;

/**
 * User: twalcari
 * Date: 9/22/2015
 * Time: 16:10
 */
public class GtsException extends Exception {
    private final RestApi.RestReply<String> reply;

    public GtsException(RestApi.RestReply<String> reply) {
        this.reply = reply;
    }

    public GtsException(String message, RestApi.RestReply<String> reply) {
        super(message);
        this.reply = reply;
    }

    public GtsException(String message, Throwable cause, RestApi.RestReply<String> reply) {
        super(message, cause);
        this.reply = reply;
    }

    public GtsException(Throwable cause, RestApi.RestReply<String> reply) {
        super(cause);
        this.reply = reply;
    }

    public GtsException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace, RestApi.RestReply<String> reply) {
        super(message, cause, enableSuppression, writableStackTrace);
        this.reply = reply;
    }


    public GtsException() {
        this.reply = null;
    }

    public GtsException(String message) {
        super(message);
        this.reply = null;
    }

    public GtsException(String message, Throwable cause) {
        super(message, cause);
        this.reply = null;
    }

    public GtsException(Throwable cause) {
        super(cause);
        this.reply = null;
    }

    public GtsException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
        super(message, cause, enableSuppression, writableStackTrace);
        this.reply = null;
    }

    public RestApi.RestReply<String> getReply() {
        return reply;
    }

    @Override
    public String getMessage() {
        String result =  super.getMessage();
        if(reply != null) {
           result += " - reply: " + reply;
        }

        return result;
    }

    @Override
    public String getLocalizedMessage() {
        String result =  super.getLocalizedMessage();
        if(reply != null) {
            result += " - reply: " + reply;
        }

        return result;
    }
}
