From c53dc3f8677cd4206411f90d23ef7be81176580e Mon Sep 17 00:00:00 2001 From: Claudia Murialdo Date: Wed, 25 May 2022 14:46:18 -0300 Subject: [PATCH] Improve message of exceptions when handling OUTPUT_FILE_DIRECTORY property and when looking for a true type font in file system. --- .../GxPdfReportsCS/PDFReportItext.cs | 31 ++++++++++++++----- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/dotnet/src/dotnetframework/GxPdfReportsCS/PDFReportItext.cs b/dotnet/src/dotnetframework/GxPdfReportsCS/PDFReportItext.cs index a189a08bc..2797897dc 100644 --- a/dotnet/src/dotnetframework/GxPdfReportsCS/PDFReportItext.cs +++ b/dotnet/src/dotnetframework/GxPdfReportsCS/PDFReportItext.cs @@ -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 { @@ -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; }