Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve exception messages when generating pdf reports #597

Merged
merged 1 commit into from
May 31, 2022
Merged
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
31 changes: 23 additions & 8 deletions dotnet/src/dotnetframework/GxPdfReportsCS/PDFReportItext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -985,8 +985,15 @@ public void GxAttris(String fontName, int fontSize, bool fontBold, bool fontItal
{
if (IsEmbeddedFont(fontName))
{
baseFont = BaseFont.CreateFont(fontPath, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
GXLogging.Debug(log,"EMBEED_SECTION Font");
try
{
baseFont = BaseFont.CreateFont(fontPath, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
GXLogging.Debug(log, "EMBEED_SECTION Font");
}catch (IOException ioEx)
{
Exception exDetailed = new Exception($"Error creating {fontPath}. Check font is installed for the current user", ioEx);
throw exDetailed;
}
}
else
{
Expand Down Expand Up @@ -2062,14 +2069,22 @@ public void GxSetDocName(String docName)
string outputDir = props.getGeneralProperty(Const.OUTPUT_FILE_DIRECTORY, "").Replace(alternateSeparator, Path.DirectorySeparatorChar).Trim();
if(!string.IsNullOrEmpty(outputDir) && outputDir!=".")
{
if(!outputDir.EndsWith(Path.DirectorySeparatorChar.ToString()))
try
{
outputDir += Path.DirectorySeparatorChar;
}
string []dirs = Directory.GetDirectories(outputDir);
foreach(string dir in dirs)
if (!outputDir.EndsWith(Path.DirectorySeparatorChar.ToString()))
{
outputDir += Path.DirectorySeparatorChar;
}
string[] dirs = Directory.GetDirectories(outputDir);
foreach (string dir in dirs)
{
Directory.CreateDirectory(dir);
}
}catch (Exception ex)
{
Directory.CreateDirectory(dir);
Exception exDetailed = new Exception($"Error creating {Const.OUTPUT_FILE_DIRECTORY} of {Const.INI_FILE} ({outputDir})", ex);
GXLogging.Error(log, "GxSetDocName error", exDetailed);
throw exDetailed;
}
this.docName = outputDir + this.docName;
}
Expand Down