diff --git a/Iceshrimp.Frontend/Core/Services/EmojiService.cs b/Iceshrimp.Frontend/Core/Services/EmojiService.cs index 31672503..b82ab888 100644 --- a/Iceshrimp.Frontend/Core/Services/EmojiService.cs +++ b/Iceshrimp.Frontend/Core/Services/EmojiService.cs @@ -1,12 +1,15 @@ +using System.Text.Json; +using Iceshrimp.Frontend.Components; using Iceshrimp.Frontend.Core.Miscellaneous; using Iceshrimp.Shared.Schemas.Web; using Microsoft.AspNetCore.Components; namespace Iceshrimp.Frontend.Core.Services; -internal class EmojiService(ApiService api) +internal class EmojiService(ApiService api, GlobalComponentSvc global) { [Inject] private ApiService Api { get; set; } = api; + [Inject] private GlobalComponentSvc Global { get; set; } = global; private List? Emojis { get; set; } public async Task> GetEmojiAsync() @@ -18,10 +21,17 @@ internal class EmojiService(ApiService api) Emojis = emoji; return Emojis; } - catch (ApiException) + catch (ApiException e) { - // FIXME: Implement connection error handling - throw new Exception("Failed to fetch emoji"); + await Global.NoticeDialog?.Display(e.Response.Message ?? "Unable to load emojis", + NoticeDialog.NoticeType.Error)!; + return []; + } + catch (JsonException) + { + await Global.NoticeDialog?.Display("Emojis provided by the server didn't match what the client expected", + NoticeDialog.NoticeType.Error)!; + return []; } } } \ No newline at end of file