18 lines
574 B
C#
18 lines
574 B
C#
using System.Net;
|
|
using Bunny.Common.Exception;
|
|
|
|
namespace Bunny.Common.Utils;
|
|
|
|
public class EmptyUtil
|
|
{
|
|
/// <summary>
|
|
/// 判断对象或者字符串是否为空
|
|
/// </summary>
|
|
/// <param name="obj">传入的对象</param>
|
|
/// <param name="code">出错的状态码</param>
|
|
/// <param name="message">出错的消息</param>
|
|
public static void CheckIfNullOrEmpty(object? obj, HttpStatusCode code, string message)
|
|
{
|
|
if (obj == null || (obj is string s && string.IsNullOrEmpty(s))) throw new BunnyException(code, message);
|
|
}
|
|
} |