package com.tzy.common.exception;

import java.util.Map;

/**
 * 业务异常
 * 
 * @author zheng
 */
public class ServiceException extends RuntimeException {
    private static final long serialVersionUID = 1L;

    protected final String message;
    protected int code=0;
    /**特殊异常,抛出需要返回到前端的数据*/
    protected Map<String, Object> data;

    public ServiceException(String message)
    {
        this.code = -1;
        this.message = message;
    }

    public ServiceException(int code,String message) {
        this.message = message;
        this.code = code;
    }

    public ServiceException(int code,String message,Map<String, Object> data) {
        this.message = message;
        this.code = code;
        this.data = data;
    }

    public ServiceException(String message, Throwable e)
    {
        super(message, e);
        this.message = message;
    }

    @Override
    public String getMessage()
    {
        return message;
    }

    public int getCode()
    {
        return this.code;
    }

    public Map<String, Object> getData() {
        return data;
    }
}
