package com.qmth.file.exception;

/**
 * 系统异常信息
 * @author tianjun
 *
 */
public class FileServerException extends RuntimeException {

    private static final long serialVersionUID = -8007657202243426183L;

    public static final FileServerException SYSTEM_EXCEPTION = new FileServerException(500, "系统异常");
    public static final FileServerException FILE_MD5_NOT_MATCH = new FileServerException(504, "文件MD5校验失败");
    public static final FileServerException NOT_FILE_UPLOAD_REQUEST = new FileServerException(505, "不是文件上传的请求");

    public static final FileServerException TOKEN_INVALID = new FileServerException(-101, "token错误");
    public static final FileServerException TOKEN_NEEDED = new FileServerException(-102, "无法从请求中获取token鉴权参数");
    public static final FileServerException EXAM_CODE_INVALID = new FileServerException(-103, "考试识别码为空或者错误");
    public static final FileServerException EXAM_PLAN_DISABLED = new FileServerException(-104, "考试任务不可用");
    public static final FileServerException FILE_UPLOAD_ERROR = new FileServerException(-105, "文件上传失败");
    public static final FileServerException MISSING_PARAMS_MAC = new FileServerException(-107, "缺少参数mac");
    public static final FileServerException KW_STORE_DATA_ERROR = new FileServerException(-108, "考务数据存储错误");
    public static final FileServerException KW_STORE_KC_ERROR = new FileServerException(-109, "考务存储数据中考场文件不存在");
    public static final FileServerException PLACE_CODE_INVALID = new FileServerException(-110, "考点代码不被识别");
    public static final FileServerException ROOM_CODE_INVALID = new FileServerException(-111, "考场代码不被识别");
    public static final FileServerException EXAM_PLAN_UN_PUBLISHED = new FileServerException(-112, "考试计划没有发布");
    public static final FileServerException PARAM_MD5_MISSING = new FileServerException(-113, "请求参数中没有md5参数 ");
    public static final FileServerException SOLFEGE_RECORDS_IS_NULL = new FileServerException(-115, "参数中缺少视唱录音文件records");
    public static final FileServerException SOLFEGE_USER_INFO_IS_NULL = new FileServerException(-116, "参数中缺考生信息userInfo");
    public static final FileServerException SOLFEGE_PAPER_IS_NULL = new FileServerException(-117, "参数中缺少试卷信息");
    public static final FileServerException SOLFEGE_LOCAL_TIME_IS_NULL = new FileServerException(-118, "参数中缺少LocalTime信息");
    public static final FileServerException PLACE_CODE_IS_NULL = new FileServerException(-119, "考点代码为空");
    public static final FileServerException ROOM_CODE_IS_NULL = new FileServerException(-120, "考场代码为空");
    public static final FileServerException TIMESTAMP_IS_NULL = new FileServerException(-121, "时间戳为空");
    public static final FileServerException SIGN_INVALID = new FileServerException(-122, "签名错误");
    public static final FileServerException NOTICE_TYPE_INVALID = new FileServerException(-123, "通知类型参数错误,type不能够为空，且取值只能够是0或者1");
    public static final FileServerException BATCH_ID_INVALID = new FileServerException(-124, "批次id不能够是空的");
    public static final FileServerException PASSWORD_NOT_SET = new FileServerException(-125, "尚未设置开卷密码");


    private int code;

    private String message;

    public FileServerException(int code, String message) {
        super(message);
        this.code = code;
        this.message = message;
    }
    
    public FileServerException(String message) {
    	this(SYSTEM_EXCEPTION.getCode(), message);
    }
    
    

    public int getCode() {
        return code;
    }

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

    public static FileServerException withMessage(String message) {
        return new FileServerException(message);
    }

}
