using Microsoft.Extensions.Localization;
using Sanhe.Abp.Features.LimitValidation.Localization;
using Volo.Abp;
using Volo.Abp.ExceptionHandling;
using Volo.Abp.Localization;
namespace Sanhe.Abp.Features.LimitValidation;
public class AbpFeatureLimitException : AbpException, ILocalizeErrorMessage, IBusinessException
{
///
/// 功能名称名称
///
public string Feature { get; }
///
/// 上限
///
public int Limit { get; }
public AbpFeatureLimitException(string feature, int limit)
: base($"Features {feature} has exceeded the maximum number of calls {limit}, please apply for the appropriate permission")
{
Feature = feature;
Limit = limit;
}
public string LocalizeMessage(LocalizationContext context)
{
var localizer = context.LocalizerFactory.Create();
return localizer["FeaturesLimitException", Limit];
}
}