From 8231c057a4073e7397dbb1d953c43a76d8187e72 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 12 Feb 2018 12:53:46 +0200 Subject: Implemented global exception trapping on machine studio. --- .../ExtensionMethods/ExceptionExtensions.cs | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Software/Visual_Studio/Tango.Logging/ExtensionMethods/ExceptionExtensions.cs (limited to 'Software/Visual_Studio/Tango.Logging/ExtensionMethods/ExceptionExtensions.cs') diff --git a/Software/Visual_Studio/Tango.Logging/ExtensionMethods/ExceptionExtensions.cs b/Software/Visual_Studio/Tango.Logging/ExtensionMethods/ExceptionExtensions.cs new file mode 100644 index 000000000..d3a824a90 --- /dev/null +++ b/Software/Visual_Studio/Tango.Logging/ExtensionMethods/ExceptionExtensions.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Logging +{ + /// + /// Contains exception methods. + /// + public static class ExceptionExtensions + { + /// + /// Flattens the exception by digging on InnerException. + /// + /// The exception. + /// + public static String FlattenException(this Exception exception) + { + var stringBuilder = new StringBuilder(); + + while (exception != null) + { + stringBuilder.AppendLine(exception.Message); + stringBuilder.AppendLine(exception.StackTrace); + + exception = exception.InnerException; + } + + return stringBuilder.ToString(); + } + } +} + -- cgit v1.3.1