diff --git a/src/BiliLite.UWP/BiliLite.UWP.csproj b/src/BiliLite.UWP/BiliLite.UWP.csproj index b11cf3a7..ed2dbce8 100644 --- a/src/BiliLite.UWP/BiliLite.UWP.csproj +++ b/src/BiliLite.UWP/BiliLite.UWP.csproj @@ -185,6 +185,7 @@ + @@ -1287,4 +1288,4 @@ --> - \ No newline at end of file + diff --git a/src/BiliLite.UWP/Models/Exceptions/NotFoundException.cs b/src/BiliLite.UWP/Models/Exceptions/NotFoundException.cs new file mode 100644 index 00000000..bfbca802 --- /dev/null +++ b/src/BiliLite.UWP/Models/Exceptions/NotFoundException.cs @@ -0,0 +1,11 @@ +using System; + +namespace BiliLite.Models.Exceptions +{ + public class NotFoundException : Exception + { + public NotFoundException(string msg) : base(msg) + { + } + } +} diff --git a/src/BiliLite.UWP/Services/GrpcService.cs b/src/BiliLite.UWP/Services/GrpcService.cs index 97d11b57..4c0d6fcb 100644 --- a/src/BiliLite.UWP/Services/GrpcService.cs +++ b/src/BiliLite.UWP/Services/GrpcService.cs @@ -3,6 +3,7 @@ using Bilibili.App.Dynamic.V2; using Bilibili.App.Interface.V1; using BiliLite.gRPC.Api; +using BiliLite.Models.Exceptions; namespace BiliLite.Services { @@ -24,6 +25,11 @@ public async Task SearchSpaceArchive(string mid, int page = { var reply = SearchArchiveReply.Parser.ParseFrom(result.results); return reply; + } + // 用户搜索一个不存在的关键字导致的 + else if (result.code == -102 && result.message == "请求失败,没有数据返回") + { + throw new NotFoundException(result.message); } else { diff --git a/src/BiliLite.UWP/ViewModels/User/UserSubmitVideoViewModel.cs b/src/BiliLite.UWP/ViewModels/User/UserSubmitVideoViewModel.cs index 80777dc0..beb90779 100644 --- a/src/BiliLite.UWP/ViewModels/User/UserSubmitVideoViewModel.cs +++ b/src/BiliLite.UWP/ViewModels/User/UserSubmitVideoViewModel.cs @@ -141,13 +141,15 @@ public async Task GetSubmitVideo() LoadingSubmitVideo = true; if (string.IsNullOrEmpty(Keyword)) { - var api = m_userDetailApi.SubmitVideosCursor(Mid, order: (SubmitVideoOrder)SelectOrder, cursor: m_lastAid); + var api = m_userDetailApi.SubmitVideosCursor(Mid, order: (SubmitVideoOrder)SelectOrder, + cursor: m_lastAid); CurrentTid = SelectTid.Tid; var results = await api.Request(); if (!results.status) { throw new CustomizedErrorException(results.message); } + var data = results.GetJObject(); if (data["code"].ToInt32() != 0) { @@ -164,18 +166,19 @@ public async Task GetSubmitVideo() AttachSubmitVideoItems(submitVideoItems, (int)searchArchive.Total); } } + catch (CustomizedErrorException ex) + { + Notify.ShowMessageToast(ex.Message); + _logger.Error("获取用户投稿失败", ex); + } + catch (NotFoundException ex) + { + Notify.ShowMessageToast("(っ °Д °;)っ 没有找到相应的视频~"); + } catch (Exception ex) { - if (ex is CustomizedErrorException) - { - Notify.ShowMessageToast(ex.Message); - } - else - { - var handel = HandelError(ex); - Notify.ShowMessageToast(handel.message); - } - + var handel = HandelError(ex); + Notify.ShowMessageToast(handel.message); _logger.Error("获取用户投稿失败", ex); } finally