Skip to content

Commit a60d163

Browse files
committed
More error handling for smart format
1 parent b7b0189 commit a60d163

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@
2929
// You can specify all the values or you can default the Build and Revision Numbers
3030
// by using the '*' as shown below:
3131
// [assembly: AssemblyVersion("1.0.*")]
32-
[assembly: AssemblyVersion("2.1.1.0")]
33-
[assembly: AssemblyFileVersion("2.1.1.0")]
32+
[assembly: AssemblyVersion("2.1.2.0")]
33+
[assembly: AssemblyFileVersion("2.1.2.0")]
3434

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,39 @@
1-
using SmartFormat;
1+
using NLog;
2+
using SmartFormat;
23

34
namespace XESmartTarget.Core.Utils
45
{
56
public static class SmartFormatHelper
67
{
8+
private static Logger logger = LogManager.GetCurrentClassLogger();
9+
10+
private static SmartFormatter fmt = Smart.CreateDefaultSmartFormat();
711
public static string Format(string format, Dictionary<string, string> args)
812
{
9-
var fmt = Smart.CreateDefaultSmartFormat();
10-
fmt.Settings.Parser.ConvertCharacterStringLiterals = false;
11-
return fmt.Format(format, args);
13+
try
14+
{
15+
fmt.Settings.Parser.ConvertCharacterStringLiterals = false;
16+
return fmt.Format(format, args);
17+
}
18+
catch (Exception e)
19+
{
20+
logger.Debug(e.Message);
21+
return format;
22+
}
1223
}
1324

1425
public static string Format(string format, Dictionary<string, object> args)
1526
{
16-
var fmt = Smart.CreateDefaultSmartFormat();
17-
fmt.Settings.Parser.ConvertCharacterStringLiterals = false;
18-
return fmt.Format(format, args);
27+
try
28+
{
29+
fmt.Settings.Parser.ConvertCharacterStringLiterals = false;
30+
return fmt.Format(format, args);
31+
}
32+
catch (Exception e)
33+
{
34+
logger.Debug(e.Message);
35+
return format;
36+
}
1937
}
2038
}
2139
}

0 commit comments

Comments
 (0)