diff --git a/common.props b/common.props index 42cab34..e365970 100644 --- a/common.props +++ b/common.props @@ -1,7 +1,7 @@ latest - 1.3.3 + 1.4.0 $(NoWarn);CS1591 true EasyAbp Team diff --git a/src/EasyAbp.Abp.Sms.TencentCloud/EasyAbp/Abp/Sms/TencentCloud/FailedToSendSmsException.cs b/src/EasyAbp.Abp.Sms.TencentCloud/EasyAbp/Abp/Sms/TencentCloud/FailedToSendSmsException.cs new file mode 100644 index 0000000..c6af90a --- /dev/null +++ b/src/EasyAbp.Abp.Sms.TencentCloud/EasyAbp/Abp/Sms/TencentCloud/FailedToSendSmsException.cs @@ -0,0 +1,12 @@ +using Volo.Abp; + +namespace EasyAbp.Abp.Sms.TencentCloud +{ + public class FailedToSendSmsException : AbpException + { + public FailedToSendSmsException(string code, string message) : base( + $"Tencent Cloud API responses an error: [{code}] {message}.") + { + } + } +} \ No newline at end of file diff --git a/src/EasyAbp.Abp.Sms.TencentCloud/EasyAbp/Abp/Sms/TencentCloud/InvalidTemplateParamSetException.cs b/src/EasyAbp.Abp.Sms.TencentCloud/EasyAbp/Abp/Sms/TencentCloud/InvalidTemplateParamSetException.cs index 84a7c64..cc6de08 100644 --- a/src/EasyAbp.Abp.Sms.TencentCloud/EasyAbp/Abp/Sms/TencentCloud/InvalidTemplateParamSetException.cs +++ b/src/EasyAbp.Abp.Sms.TencentCloud/EasyAbp/Abp/Sms/TencentCloud/InvalidTemplateParamSetException.cs @@ -1,10 +1,11 @@ -using System; +using Volo.Abp; namespace EasyAbp.Abp.Sms.TencentCloud { - public class InvalidTemplateParamSetException : ApplicationException + public class InvalidTemplateParamSetException : AbpException { - public InvalidTemplateParamSetException() : base("TemplateParamSet should be IEnumerable.") + public InvalidTemplateParamSetException() : base( + "TemplateParamSet should be IEnumerable or JSON string collection.") { } } diff --git a/src/EasyAbp.Abp.Sms.TencentCloud/EasyAbp/Abp/Sms/TencentCloud/TencentCloudSmsSender.cs b/src/EasyAbp.Abp.Sms.TencentCloud/EasyAbp/Abp/Sms/TencentCloud/TencentCloudSmsSender.cs index bb1028d..1fce24f 100644 --- a/src/EasyAbp.Abp.Sms.TencentCloud/EasyAbp/Abp/Sms/TencentCloud/TencentCloudSmsSender.cs +++ b/src/EasyAbp.Abp.Sms.TencentCloud/EasyAbp/Abp/Sms/TencentCloud/TencentCloudSmsSender.cs @@ -52,8 +52,13 @@ await _settingProvider.GetOrNullAsync(AbpSmsTencentCloudSettings.DefaultSenderId Region = await _settingProvider.GetOrNullAsync(AbpSmsTencentCloudSettings.DefaultRegion) }; - await _requester.SendRequestAsync(request, + var response = await _requester.SendRequestAsync(request, await _settingProvider.GetOrNullAsync(AbpSmsTencentCloudSettings.EndPoint), commonOptions); + + if (response.Error != null) + { + throw new FailedToSendSmsException(response.Error.Code, response.Error.Message); + } } protected virtual string GetStringProperty(SmsMessage smsMessage, string key, string defaultValue = null)