Skip to content

Commit

Permalink
feat: 处理异常
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhaoYis committed May 21, 2024
1 parent c54852a commit f259a72
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/Berry.Spider.NaiPan/NaiPanService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ namespace Berry.Spider.NaiPan;

public class NaiPanService : INaiPanService
{
private static readonly weiyuanchuangPortTypeClient NaiPanClient = new(weiyuanchuangPortTypeClient.EndpointConfiguration.weiyuanchuangHttpSoap12Endpoint);

private NaiPanOptions Options { get; }

public NaiPanService(IOptionsSnapshot<NaiPanOptions> options)
Expand All @@ -20,13 +22,19 @@ public async Task<string> GenerateAsync(string content)
{
if (this.Options is { IsEnabled: true })
{
weiyuanchuangPortTypeClient client = new weiyuanchuangPortTypeClient(weiyuanchuangPortTypeClient.EndpointConfiguration.weiyuanchuangHttpSoap12Endpoint);

weiyuanchuangRequest request = new weiyuanchuangRequest(this.Options.Account, this.Options.Secret, content);
weiyuanchuangResponse response = await client.weiyuanchuangAsync(request);
if (response is not null)
try
{
weiyuanchuangRequest request = new weiyuanchuangRequest(this.Options.Account, this.Options.Secret, content);
weiyuanchuangResponse response = await NaiPanClient.weiyuanchuangAsync(request);
if (response is not null)
{
return response.@return;
}
}
catch (Exception e)
{
return response.@return;
Console.WriteLine(e.ToString());
return content;
}
}

Expand Down

0 comments on commit f259a72

Please sign in to comment.