From 7213d90755fe47448f0d99ba495b0abb7d86dd91 Mon Sep 17 00:00:00 2001 From: LTRData Date: Fri, 24 May 2024 14:10:34 +0200 Subject: [PATCH] Improved exception message * Improved exception message when attempting to open a partial image file without an embedded descriptor --- Library/DiscUtils.Vmdk/DiskImageFile.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Library/DiscUtils.Vmdk/DiskImageFile.cs b/Library/DiscUtils.Vmdk/DiskImageFile.cs index 1687f3613..e9cbdcbf4 100644 --- a/Library/DiscUtils.Vmdk/DiskImageFile.cs +++ b/Library/DiscUtils.Vmdk/DiskImageFile.cs @@ -145,6 +145,11 @@ internal DiskImageFile(FileLocator fileLocator, string file, FileAccess access) fileStream = fileLocator.Open(file, FileMode.Open, fileAccess, fileShare); LoadDescriptor(fileStream); + if (_descriptor is null) + { + throw new InvalidOperationException($"This VMDK image file does not contain an embedded descriptor"); + } + // For monolithic disks, keep hold of the stream - we won't try to use the file name // from the embedded descriptor because the file may have been renamed, making the // descriptor out of date.