diff --git a/Aaru.Devices/Aaru.Devices.csproj b/Aaru.Devices/Aaru.Devices.csproj index 049e5053c..ab6c032f5 100644 --- a/Aaru.Devices/Aaru.Devices.csproj +++ b/Aaru.Devices/Aaru.Devices.csproj @@ -56,7 +56,6 @@ false - diff --git a/Aaru.Devices/Device/Constructor.cs b/Aaru.Devices/Device/Constructor.cs index a197f0c66..638adb433 100644 --- a/Aaru.Devices/Device/Constructor.cs +++ b/Aaru.Devices/Device/Constructor.cs @@ -50,10 +50,11 @@ public partial class Device { /// Opens the device for sending direct commands /// Device path - public static Device Create(string devicePath) + public static Device Create(string devicePath, out ErrorNumber errno) { Device dev = null; Uri aaruUri; + errno = ErrorNumber.NoError; try { @@ -61,18 +62,20 @@ public partial class Device } catch(Exception) { - return null; + aaruUri = null; } - if(aaruUri.Scheme is "dic" or "aaru") - dev = Remote.Device.Create(aaruUri); + if(aaruUri?.Scheme is "dic" or "aaru") + dev = Remote.Device.Create(aaruUri, out errno); else if(OperatingSystem.IsLinux()) - dev = Linux.Device.Create(devicePath); + dev = Linux.Device.Create(devicePath, out errno); else if(OperatingSystem.IsWindows()) - dev = Windows.Device.Create(devicePath); + dev = Windows.Device.Create(devicePath, out errno); + else + errno = ErrorNumber.NotSupported; if(dev is null) - throw new DeviceException("Platform not supported."); + return null; if(dev.Type == DeviceType.SCSI || dev.Type == DeviceType.ATAPI) diff --git a/Aaru.Devices/Device/DeviceException.cs b/Aaru.Devices/Device/DeviceException.cs deleted file mode 100644 index cfecf17e0..000000000 --- a/Aaru.Devices/Device/DeviceException.cs +++ /dev/null @@ -1,47 +0,0 @@ -// /*************************************************************************** -// Aaru Data Preservation Suite -// ---------------------------------------------------------------------------- -// -// Filename : DeviceException.cs -// Author(s) : Natalia Portillo -// -// Component : Devices. -// -// --[ Description ] ---------------------------------------------------------- -// -// Exception to be returned by the device constructor. -// -// --[ License ] -------------------------------------------------------------- -// -// This library is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as -// published by the Free Software Foundation; either version 2.1 of the -// License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, see . -// -// ---------------------------------------------------------------------------- -// Copyright © 2011-2022 Natalia Portillo -// ****************************************************************************/ - -namespace Aaru.Devices; - -using System; - -/// -/// Exception to be returned by the device constructor -public sealed class DeviceException : Exception -{ - internal DeviceException(string message) : base(message) {} - - internal DeviceException(int lastError) => LastError = lastError; - - /// Last error sent by the operating systen - public int LastError { get; } -} \ No newline at end of file diff --git a/Aaru.Devices/Linux/Device.cs b/Aaru.Devices/Linux/Device.cs index 4e723ea10..ec096cc78 100644 --- a/Aaru.Devices/Linux/Device.cs +++ b/Aaru.Devices/Linux/Device.cs @@ -54,8 +54,10 @@ partial class Device : Devices.Device Device() {} - internal new static Device Create(string devicePath) + internal new static Device Create(string devicePath, out ErrorNumber errno) { + errno = ErrorNumber.NoError; + var dev = new Device { PlatformId = DetectOS.GetRealPlatformID(), @@ -86,7 +88,11 @@ partial class Device : Devices.Device } if(dev.Error) - throw new DeviceException(dev.LastError); + { + errno = (ErrorNumber)dev.LastError; + + return null; + } // Seems ioctl(2) does not allow the atomicity needed if(dev.PlatformId == PlatformID.Linux) @@ -96,7 +102,11 @@ partial class Device : Devices.Device dev.ScsiType = PeripheralDeviceTypes.UnknownDevice; if(dev.Error) - throw new DeviceException(dev.LastError); + { + errno = (ErrorNumber)dev.LastError; + + return null; + } string devPath; diff --git a/Aaru.Devices/Remote/Device.cs b/Aaru.Devices/Remote/Device.cs index c73117dd6..d78889223 100644 --- a/Aaru.Devices/Remote/Device.cs +++ b/Aaru.Devices/Remote/Device.cs @@ -75,8 +75,10 @@ public sealed partial class Device : Devices.Device /// Opens the device for sending direct commands /// AaruRemote URI /// Device - internal static Device Create(Uri aaruUri) + internal static Device Create(Uri aaruUri, out ErrorNumber errno) { + errno = ErrorNumber.NoError; + var dev = new Device { PlatformId = DetectOS.GetRealPlatformID(), @@ -100,11 +102,16 @@ public sealed partial class Device : Devices.Device dev._remote = new Remote(aaruUri); - dev.Error = !dev._remote.Open(devicePath, out int errno); - dev.LastError = errno; + dev.Error = !dev._remote.Open(devicePath, out int remoteErrno); + dev.LastError = remoteErrno; + // TODO: Convert error codes if(dev.Error) - throw new DeviceException(dev.LastError); + { + errno = (ErrorNumber)remoteErrno; + + return null; + } if(dev._remote.ServerOperatingSystem == "Linux") _readMultipleBlockCannotSetBlockCount = true; @@ -113,7 +120,12 @@ public sealed partial class Device : Devices.Device dev.ScsiType = PeripheralDeviceTypes.UnknownDevice; if(dev.Error) - throw new DeviceException(dev.LastError); + if(dev.Error) + { + errno = (ErrorNumber)dev.LastError; + + return null; + } dev.Type = dev._remote.GetDeviceType(); diff --git a/Aaru.Devices/Windows/Device.cs b/Aaru.Devices/Windows/Device.cs index 64b74dcad..d611c4ede 100644 --- a/Aaru.Devices/Windows/Device.cs +++ b/Aaru.Devices/Windows/Device.cs @@ -51,8 +51,10 @@ partial class Device : Devices.Device Device() {} - internal new static Device Create(string devicePath) + internal new static Device Create(string devicePath, out ErrorNumber errno) { + errno = ErrorNumber.NoError; + var dev = new Device { PlatformId = DetectOS.GetRealPlatformID(), @@ -71,13 +73,21 @@ partial class Device : Devices.Device } if(dev.Error) - throw new DeviceException(dev.LastError); + { + errno = (ErrorNumber)dev.LastError; + + return null; + } dev.Type = DeviceType.Unknown; dev.ScsiType = PeripheralDeviceTypes.UnknownDevice; if(dev.Error) - throw new DeviceException(dev.LastError); + { + errno = (ErrorNumber)dev.LastError; + + return null; + } // Windows is answering SCSI INQUIRY for all device types so it needs to be detected first var query = new StoragePropertyQuery(); diff --git a/Aaru.Gui/ViewModels/Windows/MainWindowViewModel.cs b/Aaru.Gui/ViewModels/Windows/MainWindowViewModel.cs index 3bfb0b902..faf352aac 100644 --- a/Aaru.Gui/ViewModels/Windows/MainWindowViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/MainWindowViewModel.cs @@ -35,7 +35,6 @@ namespace Aaru.Gui.ViewModels.Windows; using System; using System.Collections.Generic; using System.Collections.ObjectModel; -using System.Diagnostics; using System.IO; using System.Linq; using System.Reactive; @@ -246,74 +245,72 @@ public sealed class MainWindowViewModel : ViewModelBase case DeviceModel deviceModel: { if(deviceModel.ViewModel is null) - try - { - var dev = Device.Create(deviceModel.Path); + { + var dev = Device.Create(deviceModel.Path, out ErrorNumber devErrno); - if(dev is Devices.Remote.Device remoteDev) + switch(dev) + { + case null: + ContentPanel = $"Error {devErrno} opening device"; + + return; + case Devices.Remote.Device remoteDev: Statistics.AddRemote(remoteDev.RemoteApplication, remoteDev.RemoteVersion, remoteDev.RemoteOperatingSystem, remoteDev.RemoteOperatingSystemVersion, remoteDev.RemoteArchitecture); - if(dev.Error) - { - ContentPanel = $"Error {dev.LastError} opening device"; - - return; - } - - var devInfo = new DeviceInfo(dev); - - deviceModel.ViewModel = new DeviceInfoViewModel(devInfo, _view); - - if(!dev.IsRemovable) - deviceModel.Media.Add(new MediaModel - { - NonRemovable = true, - Name = "Non-removable device commands not yet implemented" - }); - else - { - // TODO: Removable non-SCSI? - var scsiInfo = new ScsiInfo(dev); - - if(!scsiInfo.MediaInserted) - deviceModel.Media.Add(new MediaModel - { - NoMediaInserted = true, - Icon = _ejectIcon, - Name = "No media inserted" - }); - else - { - var mediaResource = - new Uri($"avares://Aaru.Gui/Assets/Logos/Media/{scsiInfo.MediaType}.png"); - - deviceModel.Media.Add(new MediaModel - { - DevicePath = deviceModel.Path, - Icon = _assets.Exists(mediaResource) ? new Bitmap(_assets.Open(mediaResource)) - : null, - Name = $"{scsiInfo.MediaType}", - ViewModel = new MediaInfoViewModel(scsiInfo, deviceModel.Path, _view) - }); - } - } - - dev.Close(); + break; } - catch(SystemException ex) - { - if(Debugger.IsAttached) - throw; - ContentPanel = ex.Message; - AaruConsole.ErrorWriteLine(ex.Message); + if(dev.Error) + { + ContentPanel = $"Error {dev.LastError} opening device"; return; } + var devInfo = new DeviceInfo(dev); + + deviceModel.ViewModel = new DeviceInfoViewModel(devInfo, _view); + + if(!dev.IsRemovable) + deviceModel.Media.Add(new MediaModel + { + NonRemovable = true, + Name = "Non-removable device commands not yet implemented" + }); + else + { + // TODO: Removable non-SCSI? + var scsiInfo = new ScsiInfo(dev); + + if(!scsiInfo.MediaInserted) + deviceModel.Media.Add(new MediaModel + { + NoMediaInserted = true, + Icon = _ejectIcon, + Name = "No media inserted" + }); + else + { + var mediaResource = + new Uri($"avares://Aaru.Gui/Assets/Logos/Media/{scsiInfo.MediaType}.png"); + + deviceModel.Media.Add(new MediaModel + { + DevicePath = deviceModel.Path, + Icon = _assets.Exists(mediaResource) ? new Bitmap(_assets.Open(mediaResource)) + : null, + Name = $"{scsiInfo.MediaType}", + ViewModel = new MediaInfoViewModel(scsiInfo, deviceModel.Path, _view) + }); + } + } + + dev.Close(); + } + ContentPanel = new Views.Panels.DeviceInfo { DataContext = deviceModel.ViewModel @@ -786,10 +783,10 @@ public sealed class MainWindowViewModel : ViewModelBase Path = device.Path }; - try - { - var dev = Device.Create(device.Path); + var dev = Device.Create(device.Path, out _); + if(dev != null) + { if(dev is Devices.Remote.Device remoteDev) Statistics.AddRemote(remoteDev.RemoteApplication, remoteDev.RemoteVersion, remoteDev.RemoteOperatingSystem, remoteDev.RemoteOperatingSystemVersion, @@ -839,10 +836,6 @@ public sealed class MainWindowViewModel : ViewModelBase dev.Close(); } - catch - { - // ignored - } _devicesRoot.Devices.Add(deviceModel); } diff --git a/Aaru.Gui/ViewModels/Windows/MediaDumpViewModel.cs b/Aaru.Gui/ViewModels/Windows/MediaDumpViewModel.cs index 09343e81f..24470df75 100644 --- a/Aaru.Gui/ViewModels/Windows/MediaDumpViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/MediaDumpViewModel.cs @@ -724,25 +724,25 @@ public sealed class MediaDumpViewModel : ViewModelBase UpdateStatus("Opening device..."); - try - { - _dev = Device.Create(_devicePath); + _dev = Device.Create(_devicePath, out ErrorNumber devErrno); - if(_dev is Devices.Remote.Device remoteDev) + switch(_dev) + { + case null: + StoppingErrorMessage($"Error {devErrno} opening device."); + + return; + case Devices.Remote.Device remoteDev: Statistics.AddRemote(remoteDev.RemoteApplication, remoteDev.RemoteVersion, remoteDev.RemoteOperatingSystem, remoteDev.RemoteOperatingSystemVersion, remoteDev.RemoteArchitecture); - if(_dev.Error) - { - StoppingErrorMessage($"Error {_dev.LastError} opening device."); - - return; - } + break; } - catch(Exception exception) + + if(_dev.Error) { - StoppingErrorMessage($"Exception {exception.Message} opening device."); + StoppingErrorMessage($"Error {_dev.LastError} opening device."); return; } diff --git a/Aaru.Gui/ViewModels/Windows/MediaScanViewModel.cs b/Aaru.Gui/ViewModels/Windows/MediaScanViewModel.cs index 4847fcdea..9334cc00f 100644 --- a/Aaru.Gui/ViewModels/Windows/MediaScanViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/MediaScanViewModel.cs @@ -36,6 +36,7 @@ using System.Collections.ObjectModel; using System.Reactive; using System.Threading; using System.Threading.Tasks; +using Aaru.CommonTypes.Enums; using Aaru.Core; using Aaru.Core.Devices.Scanning; using Aaru.Devices; @@ -328,11 +329,28 @@ public sealed class MediaScanViewModel : ViewModelBase char.IsLetter(_devicePath[0])) _devicePath = "\\\\.\\" + char.ToUpper(_devicePath[0]) + ':'; - var dev = Device.Create(_devicePath); + var dev = Device.Create(_devicePath, out ErrorNumber devErrno); - if(dev is Devices.Remote.Device remoteDev) - Statistics.AddRemote(remoteDev.RemoteApplication, remoteDev.RemoteVersion, remoteDev.RemoteOperatingSystem, - remoteDev.RemoteOperatingSystemVersion, remoteDev.RemoteArchitecture); + switch(dev) + { + case null: + await MessageBoxManager. + GetMessageBoxStandardWindow("Error", $"Error {devErrno} opening device.", ButtonEnum.Ok, + Icon.Error).ShowDialog(_view); + + StopVisible = false; + StartVisible = true; + CloseVisible = true; + ProgressVisible = false; + + return; + case Devices.Remote.Device remoteDev: + Statistics.AddRemote(remoteDev.RemoteApplication, remoteDev.RemoteVersion, + remoteDev.RemoteOperatingSystem, remoteDev.RemoteOperatingSystemVersion, + remoteDev.RemoteArchitecture); + + break; + } if(dev.Error) { diff --git a/Aaru.Tests.Devices/Device.cs b/Aaru.Tests.Devices/Device.cs index 27a8518f2..0d3e0d45a 100644 --- a/Aaru.Tests.Devices/Device.cs +++ b/Aaru.Tests.Devices/Device.cs @@ -39,7 +39,7 @@ static partial class MainClass AaruConsole.WriteLine("Going to open {0}. Press any key to continue...", devPath); Console.ReadKey(); - var dev = Aaru.Devices.Device.Create(devPath); + var dev = Aaru.Devices.Device.Create(devPath, out _); while(true) { diff --git a/Aaru/Commands/Device/DeviceReport.cs b/Aaru/Commands/Device/DeviceReport.cs index 894608b17..7cad63a33 100644 --- a/Aaru/Commands/Device/DeviceReport.cs +++ b/Aaru/Commands/Device/DeviceReport.cs @@ -50,7 +50,6 @@ using Aaru.Database; using Aaru.Database.Models; using Aaru.Decoders.SCSI; using Aaru.Decoders.SCSI.MMC; -using Aaru.Devices; using Aaru.Helpers; using Aaru.Settings; using Newtonsoft.Json; @@ -124,27 +123,25 @@ sealed class DeviceReportCommand : Command char.IsLetter(devicePath[0])) devicePath = "\\\\.\\" + char.ToUpper(devicePath[0]) + ':'; - Device dev; + var dev = Device.Create(devicePath, out ErrorNumber devErrno); - try + switch(dev) { - dev = Device.Create(devicePath); + case null: + AaruConsole.ErrorWriteLine($"Could not open device, error {devErrno}."); - if(dev is Devices.Remote.Device remoteDev) + return (int)devErrno; + case Devices.Remote.Device remoteDev: Statistics.AddRemote(remoteDev.RemoteApplication, remoteDev.RemoteVersion, remoteDev.RemoteOperatingSystem, remoteDev.RemoteOperatingSystemVersion, remoteDev.RemoteArchitecture); - if(dev.Error) - { - AaruConsole.ErrorWriteLine(Error.Print(dev.LastError)); - - return (int)ErrorNumber.CannotOpenDevice; - } + break; } - catch(DeviceException e) + + if(dev.Error) { - AaruConsole.ErrorWriteLine(e.Message); + AaruConsole.ErrorWriteLine(Error.Print(dev.LastError)); return (int)ErrorNumber.CannotOpenDevice; } diff --git a/Aaru/Commands/Device/Info.cs b/Aaru/Commands/Device/Info.cs index 415784a66..3bd700045 100644 --- a/Aaru/Commands/Device/Info.cs +++ b/Aaru/Commands/Device/Info.cs @@ -128,27 +128,25 @@ sealed class DeviceInfoCommand : Command char.IsLetter(devicePath[0])) devicePath = "\\\\.\\" + char.ToUpper(devicePath[0]) + ':'; - Device dev; + var dev = Device.Create(devicePath, out ErrorNumber devErrno); - try + switch(dev) { - dev = Device.Create(devicePath); + case null: + AaruConsole.ErrorWriteLine($"Could not open device, error {devErrno}."); - if(dev is Devices.Remote.Device remoteDev) + return (int)devErrno; + case Devices.Remote.Device remoteDev: Statistics.AddRemote(remoteDev.RemoteApplication, remoteDev.RemoteVersion, remoteDev.RemoteOperatingSystem, remoteDev.RemoteOperatingSystemVersion, remoteDev.RemoteArchitecture); - if(dev.Error) - { - AaruConsole.ErrorWriteLine(Error.Print(dev.LastError)); - - return (int)ErrorNumber.CannotOpenDevice; - } + break; } - catch(DeviceException e) + + if(dev.Error) { - AaruConsole.ErrorWriteLine(e.Message); + AaruConsole.ErrorWriteLine(Error.Print(dev.LastError)); return (int)ErrorNumber.CannotOpenDevice; } diff --git a/Aaru/Commands/Media/Dump.cs b/Aaru/Commands/Media/Dump.cs index 69bce71ba..304b04ffc 100644 --- a/Aaru/Commands/Media/Dump.cs +++ b/Aaru/Commands/Media/Dump.cs @@ -536,34 +536,37 @@ sealed class DumpMediaCommand : Command char.IsLetter(devicePath[0])) devicePath = "\\\\.\\" + char.ToUpper(devicePath[0]) + ':'; - Device dev = null; + Device dev = null; + ErrorNumber devErrno = ErrorNumber.NoError; - try + Spectre.ProgressSingleSpinner(ctx => { - Spectre.ProgressSingleSpinner(ctx => - { - ctx.AddTask("Opening device...").IsIndeterminate(); - dev = Device.Create(devicePath); - }); + ctx.AddTask("Opening device...").IsIndeterminate(); + dev = Device.Create(devicePath, out devErrno); + }); - if(dev is Devices.Remote.Device remoteDev) - Statistics.AddRemote(remoteDev.RemoteApplication, remoteDev.RemoteVersion, - remoteDev.RemoteOperatingSystem, remoteDev.RemoteOperatingSystemVersion, - remoteDev.RemoteArchitecture); - - if(dev.Error) + switch(dev) + { + case null: { - AaruConsole.ErrorWriteLine(Error.Print(dev.LastError)); + AaruConsole.ErrorWriteLine($"Could not open device, error {devErrno}."); if(isResponse) continue; - return (int)ErrorNumber.CannotOpenDevice; + return (int)devErrno; } + case Devices.Remote.Device remoteDev: + Statistics.AddRemote(remoteDev.RemoteApplication, remoteDev.RemoteVersion, + remoteDev.RemoteOperatingSystem, remoteDev.RemoteOperatingSystemVersion, + remoteDev.RemoteArchitecture); + + break; } - catch(DeviceException e) + + if(dev.Error) { - AaruConsole.ErrorWriteLine(e.Message ?? Error.Print(e.LastError)); + AaruConsole.ErrorWriteLine(Error.Print(dev.LastError)); if(isResponse) continue; diff --git a/Aaru/Commands/Media/Info.cs b/Aaru/Commands/Media/Info.cs index 708e24786..664b17ebd 100644 --- a/Aaru/Commands/Media/Info.cs +++ b/Aaru/Commands/Media/Info.cs @@ -52,7 +52,6 @@ using Aaru.Decoders.DVD; using Aaru.Decoders.SCSI.MMC; using Aaru.Decoders.SCSI.SSC; using Aaru.Decoders.Xbox; -using Aaru.Devices; using Aaru.Settings; using Spectre.Console; using BCA = Aaru.Decoders.Bluray.BCA; @@ -129,31 +128,32 @@ sealed class MediaInfoCommand : Command char.IsLetter(devicePath[0])) devicePath = "\\\\.\\" + char.ToUpper(devicePath[0]) + ':'; - Device dev = null; + Device dev = null; + ErrorNumber devErrno = ErrorNumber.NoError; - try + Spectre.ProgressSingleSpinner(ctx => { - Spectre.ProgressSingleSpinner(ctx => - { - ctx.AddTask("Opening device...").IsIndeterminate(); - dev = Device.Create(devicePath); - }); + ctx.AddTask("Opening device...").IsIndeterminate(); + dev = Device.Create(devicePath, out devErrno); + }); - if(dev is Devices.Remote.Device remoteDev) + switch(dev) + { + case null: + AaruConsole.ErrorWriteLine($"Could not open device, error {devErrno}."); + + return (int)devErrno; + case Devices.Remote.Device remoteDev: Statistics.AddRemote(remoteDev.RemoteApplication, remoteDev.RemoteVersion, remoteDev.RemoteOperatingSystem, remoteDev.RemoteOperatingSystemVersion, remoteDev.RemoteArchitecture); - if(dev.Error) - { - AaruConsole.ErrorWriteLine(Error.Print(dev.LastError)); - - return (int)ErrorNumber.CannotOpenDevice; - } + break; } - catch(DeviceException e) + + if(dev.Error) { - AaruConsole.ErrorWriteLine(e.Message); + AaruConsole.ErrorWriteLine(Error.Print(dev.LastError)); return (int)ErrorNumber.CannotOpenDevice; } diff --git a/Aaru/Commands/Media/Scan.cs b/Aaru/Commands/Media/Scan.cs index 0c8b5bebc..ccfd5111f 100644 --- a/Aaru/Commands/Media/Scan.cs +++ b/Aaru/Commands/Media/Scan.cs @@ -130,31 +130,32 @@ sealed class MediaScanCommand : Command char.IsLetter(devicePath[0])) devicePath = "\\\\.\\" + char.ToUpper(devicePath[0]) + ':'; - Device dev = null; + Device dev = null; + ErrorNumber devErrno = ErrorNumber.NoError; - try + Spectre.ProgressSingleSpinner(ctx => { - Spectre.ProgressSingleSpinner(ctx => - { - ctx.AddTask("Opening device...").IsIndeterminate(); - dev = Device.Create(devicePath); - }); + ctx.AddTask("Opening device...").IsIndeterminate(); + dev = Device.Create(devicePath, out devErrno); + }); - if(dev is Devices.Remote.Device remoteDev) + switch(dev) + { + case null: + AaruConsole.ErrorWriteLine($"Could not open device, error {devErrno}."); + + return (int)devErrno; + case Devices.Remote.Device remoteDev: Statistics.AddRemote(remoteDev.RemoteApplication, remoteDev.RemoteVersion, remoteDev.RemoteOperatingSystem, remoteDev.RemoteOperatingSystemVersion, remoteDev.RemoteArchitecture); - if(dev.Error) - { - AaruConsole.ErrorWriteLine(Error.Print(dev.LastError)); - - return (int)ErrorNumber.CannotOpenDevice; - } + break; } - catch(DeviceException e) + + if(dev.Error) { - AaruConsole.ErrorWriteLine(e.Message); + AaruConsole.ErrorWriteLine(Error.Print(dev.LastError)); return (int)ErrorNumber.CannotOpenDevice; }