Error handling system added
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using Avalonia.Controls;
|
||||
@@ -7,6 +8,7 @@ using Avalonia.Platform.Storage;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using GazpromApp.Enums;
|
||||
using GazpromApp.Messages;
|
||||
using GazpromApp.Models;
|
||||
|
||||
@@ -57,7 +59,22 @@ public partial class EditEquipmentDialogViewModel : ViewModelBase
|
||||
|
||||
IsImageSelected = files.Count > 0;
|
||||
|
||||
Image = IsImageSelected ? new ImageViewModel(new Models.Image()) { FileName = new Bitmap(HttpUtility.UrlDecode(files[0].Path.AbsolutePath)) } : null;
|
||||
try
|
||||
{
|
||||
Image = IsImageSelected ? new ImageViewModel(new Models.Image()) { FileName = new Bitmap(HttpUtility.UrlDecode(files[0].Path.AbsolutePath)) } : null;
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
Error error = new Error()
|
||||
{
|
||||
Title = "Ошибка обработки картинки",
|
||||
Message = "Картинка не была добавлена",
|
||||
Severity = ErrorSeverity.Error,
|
||||
};
|
||||
_ = await WeakReferenceMessenger.Default.Send(new ErrorMessage(new ErrorViewModel(error)));
|
||||
|
||||
IsImageSelected = false;
|
||||
}
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
|
||||
Reference in New Issue
Block a user