Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<IncludeFrameworkShims>true</IncludeFrameworkShims>
Expand Down
15 changes: 13 additions & 2 deletions src/DocumentFormat.OpenXml.Framework/Packaging/OpenXmlPart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,19 @@ internal void Load(OpenXmlPackage? openXmlPackage, OpenXmlPart? parent, Uri uriT

SetPackage(openXmlPackage, parent);

// TODO: should we delay load?
var part = _openXmlPackage.Features.GetRequired<IPackageFeature>().Package.GetPart(uriTarget);
IPackagePart? part = null;
try
{
// TODO: should we delay load?
part = _openXmlPackage.Features.GetRequired<IPackageFeature>().Package.GetPart(uriTarget);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we make the Getpart return null when there's this failure? Then we can just check for a null

}
catch (InvalidOperationException ex)
{
var errorMessage = SR.Format(
ExceptionMessages.SpecifiedPartNotFound,
uriTarget.OriginalString, ex.Message);
throw new InvalidOperationException(errorMessage);
}

Features.Set<IPackagePartFeature>(new PackagePartFeature(part));

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -417,4 +417,9 @@
<data name="EncryptedPackageNotSupported" xml:space="preserve">
<value>Encrypted packages are not supported.</value>
</data>
<data name="SpecifiedPartNotFound" xml:space="preserve">
<value> Part: {0} doesn't exist in the package.

Original Message:{1}</value>
</data>
</root>
Loading