SqlSugar\Src\Asp.Net\SqlSugar\Utilities\Check.cs
功能:SqlSugar异常处理静态函数
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SqlSugar
{
public class Check
{
///
/// 根据传入字符串抛出UtilException
///
/// 空字符串抛出默认NotSupportedException,非空则根据message抛出UtilExceptions
public static void ThrowNotSupportedException(string message)
{
message = message.IsNullOrEmpty() ? new NotSupportedException().Message : message;
throw new UtilExceptions("SqlSugarException.NotSupportedException:" + message);
}
///
/// 根据传入的checkObj和message判断
/// 如果checkObj为空则抛出UtilException,并用message填充
///
/// 待判断Obj
/// 异常填充message字符串
public static void ArgumentNullException(object checkObj, string message)
{
if (checkObj == null)
throw new UtilExceptions("SqlSugarException.ArgumentNullException:" + message);
}
///
/// 判断传入checkObj数组是否为空
///
/// 传入Obj数组
/// 异常填充字符串
public static void ArgumentNullException(object [] checkObj, string message)
{
//checkOjb是否为空或者checkOjb数组成员为0
if (checkObj == null || checkObj.Length==0)
throw new UtilExceptions("SqlSugarException.ArgumentNullException:" + message);
}
///
/// 根据参数判断并抛出UtilExceptions
///
/// 是否Exception标记变量
/// 异常Message
/// 异常Message格式化参数
public static void Exception(bool isException, string message, params string[] args)
{
if (isException)
throw new UtilExceptions(string.Format(message, args));
}
}
}