Skip to content

Commit 8164c3d

Browse files
committed
flattening errors before logging
1 parent 69c5a6f commit 8164c3d

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/WebJobs.Script/Host/ScriptHost.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ private Collection<FunctionDescriptor> ReadFunctions(IEnumerable<FunctionDescrip
635635
catch (Exception ex)
636636
{
637637
// log any unhandled exceptions and continue
638-
AddFunctionError(functionName, ex.Message);
638+
AddFunctionError(functionName, Utility.FlattenException(ex, includeSource: false));
639639
}
640640
}
641641

@@ -669,7 +669,7 @@ internal static bool TryParseFunctionMetadata(string functionName, JObject funct
669669
string scriptFile = DeterminePrimaryScriptFile(functionConfig, functionFiles);
670670
if (string.IsNullOrEmpty(scriptFile))
671671
{
672-
error =
672+
error =
673673
"Unable to determine the primary function script. Try renaming your entry point script to 'run' (or 'index' in the case of Node), " +
674674
"or alternatively you can specify the name of the entry point script explicitly by adding a 'scriptFile' property to your function metadata.";
675675
return false;
@@ -830,7 +830,7 @@ internal Collection<FunctionDescriptor> ReadFunctions(List<FunctionMetadata> fun
830830
catch (Exception ex)
831831
{
832832
// log any unhandled exceptions and continue
833-
AddFunctionError(metadata.Name, ex.Message);
833+
AddFunctionError(metadata.Name, Utility.FlattenException(ex, includeSource: false));
834834
}
835835
}
836836

src/WebJobs.Script/Utility.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public static string GetFunctionShortName(string functionName)
4949
return functionName;
5050
}
5151

52-
public static string FlattenException(Exception ex, Func<string, string> sourceFormatter = null)
52+
public static string FlattenException(Exception ex, Func<string, string> sourceFormatter = null, bool includeSource = true)
5353
{
5454
StringBuilder flattenedErrorsBuilder = new StringBuilder();
5555
string lastError = null;
@@ -63,7 +63,7 @@ public static string FlattenException(Exception ex, Func<string, string> sourceF
6363
do
6464
{
6565
StringBuilder currentErrorBuilder = new StringBuilder();
66-
if (!string.IsNullOrEmpty(ex.Source))
66+
if (includeSource && !string.IsNullOrEmpty(ex.Source))
6767
{
6868
currentErrorBuilder.AppendFormat("{0}: ", sourceFormatter(ex.Source));
6969
}

0 commit comments

Comments
 (0)