Skip to content

Commit 5775bfc

Browse files
committed
try catch
1 parent ab136ba commit 5775bfc

4 files changed

Lines changed: 39 additions & 2 deletions

File tree

TestPlugin/DeepSeekAPI.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public static async void SendAsync(MesgInfo mesg, string httpURI, string content
4040
content = await GetUpDownContent<DeepSeekGroupModel>(mesg);
4141
prompt2 = "现在你是消息总结专家,总结时最好说明谁拉起的话题,最后一条消息是总结要求<[CQ:XXX]总结群消息,YYYYY>其中YYYYY是总结要求。无要求就简略总结";
4242
content += $"#####{content}";
43+
Console.WriteLine("DeepSeekAPI: 总结");
4344
break;
4445
default:
4546
content = await GetUpDownContent<DeepSeekModel>(mesg);
@@ -77,8 +78,14 @@ public static async void SendAsync(MesgInfo mesg, string httpURI, string content
7778
systemContent.Append("。当前时间:");
7879
systemContent.Append(DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss"));
7980
RequestJson rjson = new RequestJson(systemContent.ToString(), content);
80-
string jsonContent = JsonSerializer.Serialize(rjson);
81-
81+
string jsonContent;
82+
try {
83+
jsonContent = JsonSerializer.Serialize(rjson);
84+
} catch (Exception e) {
85+
Log.Erro("序列化出错", e.Message, e.StackTrace);
86+
SendAsync(mesg, httpURI, "呃唔,请求失败了,好像是序列化的问题。不用担心啦,没挂哦~", tk);
87+
return;
88+
}
8289
#region del
8390
//string jsonContent =
8491
// $$"""
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- https://go.microsoft.com/fwlink/?LinkID=208121. -->
3+
<Project>
4+
<PropertyGroup>
5+
<Configuration>Release</Configuration>
6+
<Platform>Any CPU</Platform>
7+
<PublishDir>D:\OpenSource\Create\灾厄WIKI\Plugin</PublishDir>
8+
<PublishProtocol>FileSystem</PublishProtocol>
9+
<_TargetId>Folder</_TargetId>
10+
<TargetFramework>net8.0</TargetFramework>
11+
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
12+
<SelfContained>false</SelfContained>
13+
<PublishSingleFile>true</PublishSingleFile>
14+
<PublishReadyToRun>false</PublishReadyToRun>
15+
</PropertyGroup>
16+
</Project>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- https://go.microsoft.com/fwlink/?LinkID=208121. -->
3+
<Project>
4+
<PropertyGroup>
5+
<History>False|2025-04-06T07:23:37.7846728Z||;</History>
6+
<LastFailureDetails />
7+
</PropertyGroup>
8+
</Project>

TestPlugin/TestPlugin.csproj.user

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<_LastSelectedProfileId>D:\OpenSource\QQbotOrWebAPI\TestPlugin\Properties\PublishProfiles\FolderProfile.pubxml</_LastSelectedProfileId>
5+
</PropertyGroup>
6+
</Project>

0 commit comments

Comments
 (0)