LoggingHelper is a helper class, which will be used throughout the project to log the exception and read the complete stack trace about the exception:
public static class LoggerHelper
{
public static string GetExceptionDetails(Exception ex)
{
StringBuilder errorString = new StringBuilder();
errorString.AppendLine("An error occured. ");
Exception inner = ex;
while (inner != null)
{
errorString.Append("Error Message:");
errorString.AppendLine(ex.Message);
errorString.Append("Stack Trace:");
errorString.AppendLine(ex.StackTrace);
inner = inner.InnerException;
}
return errorString.ToString();
}
}
More helper methods and classes can be added in the common layer, which can be used throughout the application layers.
Here is the final structure of our common layer: