Skip to content

Commit

Permalink
Merge pull request #27 from dynamicweb/frn/20240-throwing-error-if-so…
Browse files Browse the repository at this point in the history
…urcefile-doesnt-exist

Throwing errors if the sourcefile doesn't exist to avoid a nullpointe…
  • Loading branch information
frederik5480 authored Jun 26, 2024
2 parents d5f5e0a + 181e007 commit 7c95a4b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>10.4.0</Version>
<Version>10.4.1</Version>
<AssemblyVersion>1.0.0</AssemblyVersion>
<Title>Excel Provider</Title>
<Description>Excel Provider</Description>
Expand Down
16 changes: 10 additions & 6 deletions src/ExcelProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,18 +166,22 @@ void IDestination.SaveAsXml(XmlTextWriter xmlTextWriter)
{
if (!string.IsNullOrEmpty(WorkingDirectory))
{
return new ExcelSourceReader(GetSourceFilePath(), mapping, this);
var sourceFilePath = GetSourceFilePath();
if (!File.Exists(sourceFilePath))
throw new Exception($"Source file {SourceFile} does not exist - Working Directory {WorkingDirectory}");

return new ExcelSourceReader(sourceFilePath, mapping, this);
}
else
{
return new ExcelSourceReader(SourceFile, mapping, this);
if (!File.Exists(SourceFile))
throw new Exception($"Source file {SourceFile} does not exist - Working Directory {WorkingDirectory}");

return new ExcelSourceReader(SourceFile, mapping, this);
}
}
else
{
Logger?.Error("The file is not a Excel file");
return null;
}
throw new Exception("The file is not a Excel file");
}

public override void Close()
Expand Down

0 comments on commit 7c95a4b

Please sign in to comment.