You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
86 lines
2.0 KiB
C#
86 lines
2.0 KiB
C#
/**
|
|
* Haoliang.Core - 自定义异常类型
|
|
*
|
|
* 定义系统使用的自定义异常类型,用于业务逻辑验证和错误处理。
|
|
*/
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Haoliang.Core.Services
|
|
{
|
|
/// <summary>
|
|
/// 验证异常
|
|
/// </summary>
|
|
public class ValidationException : Exception
|
|
{
|
|
public Dictionary<string, string[]> Errors { get; set; } = new Dictionary<string, string[]>();
|
|
|
|
public ValidationException() : base("Validation failed")
|
|
{
|
|
}
|
|
|
|
public ValidationException(string message) : base(message)
|
|
{
|
|
}
|
|
|
|
public ValidationException(string message, Dictionary<string, string[]> errors) : base(message)
|
|
{
|
|
Errors = errors;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 资源未找到异常
|
|
/// </summary>
|
|
public class NotFoundException : Exception
|
|
{
|
|
public NotFoundException() : base("Resource not found")
|
|
{
|
|
}
|
|
|
|
public NotFoundException(string message) : base(message)
|
|
{
|
|
}
|
|
|
|
public NotFoundException(string message, Exception innerException) : base(message, innerException)
|
|
{
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 禁止访问异常
|
|
/// </summary>
|
|
public class ForbiddenException : Exception
|
|
{
|
|
public ForbiddenException() : base("Access forbidden")
|
|
{
|
|
}
|
|
|
|
public ForbiddenException(string message) : base(message)
|
|
{
|
|
}
|
|
|
|
public ForbiddenException(string message, Exception innerException) : base(message, innerException)
|
|
{
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 错误请求异常
|
|
/// </summary>
|
|
public class BadRequestException : Exception
|
|
{
|
|
public BadRequestException() : base("Bad request")
|
|
{
|
|
}
|
|
|
|
public BadRequestException(string message) : base(message)
|
|
{
|
|
}
|
|
|
|
public BadRequestException(string message, Exception innerException) : base(message, innerException)
|
|
{
|
|
}
|
|
}
|
|
} |