package com.eactive.eai.adapter.http;

import org.apache.commons.lang3.StringUtils;

public class HttpStatusException extends Exception {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private int status = 200;
	private String code;

	/** 
    * 1. 기능 :  Default Constructor
    * 2. 처리 개요 : Default Constructor
    * 3. 주의사항 
    *
    **/
	public HttpStatusException() {
		super("HttpStatusException is occured.");
	}

	/** 
    * 1. 기능 : Exception message를 초기화하는 Constructor 
    * 2. 처리 개요 : Exception message를 초기화하는 Constructor
    *     - 
    * 3. 주의사항 
    *
    * @param msg	Exception message
    **/
	public HttpStatusException(String msg) {
		super(msg);
	}
	public HttpStatusException(String msg, int status) {
		super(msg);
		this.status = status;
	}
	public HttpStatusException(String msg, String code, int status) {
		super(msg);
		this.setCode(code);
		this.status = status;
	}

	public HttpStatusException(String msg, String code, int status, Throwable cause) {
		super(msg, cause);
		this.setCode(code);
		this.status = status;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public String getCode() {
		if (StringUtils.isBlank(code)) {
			return String.format("HttCd:%d", status);
		} else {
			return code;
		}
	}

	public void setCode(String code) {
		this.code = code;
	}	
}
