wabbajack/Wabbajack.App/Screens/ErrorPageViewModel.cs

35 lines
900 B
C#
Raw Normal View History

2021-10-19 23:19:06 +00:00
using System;
using Avalonia.Controls.Mixins;
2021-10-19 23:19:06 +00:00
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
using Wabbajack.App.Messages;
using Wabbajack.App.ViewModels;
2021-10-23 16:51:17 +00:00
namespace Wabbajack.App.Screens;
public class ErrorPageViewModel : ViewModelBase
2021-10-19 23:19:06 +00:00
{
2021-10-23 16:51:17 +00:00
public ErrorPageViewModel()
{
Activator = new ViewModelActivator();
MessageBus.Current.Listen<Error>()
.Subscribe(Receive)
.DisposeWith(VMDisposables);
2021-10-23 16:51:17 +00:00
}
[Reactive] public string ShortMessage { get; set; }
[Reactive] public string Prefix { get; set; }
public void Receive(Error val)
2021-10-19 23:19:06 +00:00
{
2021-10-23 16:51:17 +00:00
Prefix = val.Prefix;
ShortMessage = val.Exception.Message;
}
2021-10-19 23:19:06 +00:00
2021-10-23 16:51:17 +00:00
public static void Display(string prefix, Exception ex)
{
MessageBus.Current.SendMessage(new Error(prefix, ex));
MessageBus.Current.SendMessage(new NavigateTo(typeof(ErrorPageViewModel)));
2021-10-19 23:19:06 +00:00
}
}