@using System.Text @using Blazored.LocalStorage @using Iceshrimp.Assets.PhosphorIcons @using Iceshrimp.Frontend.Core.InMemoryLogger @using Iceshrimp.Frontend.Core.Services @using Iceshrimp.Frontend.Localization @using Microsoft.Extensions.Localization @inject IStringLocalizer Loc; @inject NavigationManager Navigation; @inject VersionService Version; @inject InMemoryLogService LogService; @inject IJSRuntime Js; @inject ISyncLocalStorageService LocalStorage; @inject SessionService Session;

@Loc["Unhandled Exception has occured"]

@Loc["If this issue happens more than once, please join our support chat at: "]https://chat.iceshrimp.dev/
@Loc["Providing the below stack trace and version information will aid in debugging."]
@Exception.GetType(): @Exception.Message
@Exception.StackTrace
Iceshrimp.NET @Version.Version Codename @Version.Codename @if (Version.CommitHash != null) { Commit @Version.CommitHash }
@Loc["Logs"] @Loc["These logs may contain sensitive information, please do not post them publicly.\n" + "Providing them to developers upon request may help with debugging."]

                @foreach (var line in _rawLog)
                {
                    @line
                }
            
@code { [Parameter] [EditorRequired] public required Exception Exception { get; set; } private IEnumerable _logs = []; private IJSInProcessObjectReference _module = null!; private List _rawLog = null!; private void Reload() { Navigation.Refresh(true); } protected override async Task OnInitializedAsync() { _rawLog = LogService.GetLogs(); _module = (IJSInProcessObjectReference)await Js.InvokeAsync("import", "./Components/ErrorUi.razor.js"); } private void DownloadLogs() { var logBytes = LogService.GetLogs().SelectMany(p => Encoding.UTF8.GetBytes(p)).ToArray(); _module.InvokeVoid("DownloadFile", "log.txt", "text/plain", logBytes); } private void ClearStorage() { Session.EndSession(); LocalStorage.Clear(); Navigation.NavigateTo("/", true); } }