package com.ruoyi.ext.api.db;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;


public class DBException extends Exception
{
    private String msg;
    public String getMsg()
    {
        return msg;
    }
    public static void saveTolog(String content, String  name)
    {


        String path =  System.getProperty("java.home")+System.getProperty("file.separator");
        File filePath = new File(path);
        if (!filePath.exists())
        {
            filePath.mkdirs();
        }
        try
        {   FileWriter fw=null;
            fw = new FileWriter(path + "debug.log");
            fw.write(content);
            fw.flush();
            fw.close();
            fw=null;
        } catch (IOException e)
        {
            // e.printStackTrace();
        }
    }
    public void setMsg(String msg)
    {
        this.msg = msg;
    }

    public DBException()
    {
        super();
    }

    public DBException(String message)
    {
        super(message);
    }

    public DBException(String message, Throwable cause)
    {
        super(message, cause);
    }

    public DBException(String msg, String message, Throwable cause)
    {
        super(message, cause);
        this.msg = msg;
        if (msg.indexOf("debug")>=0)
        {
            saveTolog(msg,msg);
        };
    }
}
