-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more Exception details to failed messages.
- Loading branch information
1 parent
996ffc3
commit 43c30b9
Showing
13 changed files
with
73 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,34 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
using System.Threading; | ||
|
||
namespace Nimbus.Infrastructure | ||
{ | ||
public static class ExceptionExtensions | ||
{ | ||
public static Dictionary<string, object> ExceptionDetailsAsProperties(this Exception exception) | ||
public static Dictionary<string, object> ExceptionDetailsAsProperties(this Exception exception, DateTimeOffset timestamp) | ||
{ | ||
if (exception is TargetInvocationException || exception is AggregateException) return ExceptionDetailsAsProperties(exception.InnerException); | ||
if (exception is TargetInvocationException || exception is AggregateException) return ExceptionDetailsAsProperties(exception.InnerException, timestamp); | ||
|
||
return new Dictionary<string, object> | ||
{ | ||
{MessagePropertyKeys.ExceptionTypeKey, exception.GetType().FullName}, | ||
{MessagePropertyKeys.ExceptionMessageKey, exception.Message}, | ||
{MessagePropertyKeys.ExceptionStackTraceKey, exception.StackTrace}, | ||
{MessagePropertyKeys.ExceptionType, exception.GetType().FullName}, | ||
{MessagePropertyKeys.ExceptionMessage, exception.Message}, | ||
{MessagePropertyKeys.ExceptionStackTrace, exception.StackTrace}, | ||
{MessagePropertyKeys.ExceptionTimestamp, timestamp.ToString()}, | ||
{MessagePropertyKeys.ExceptionMachineName, Environment.MachineName}, | ||
{MessagePropertyKeys.ExceptionIdentityName, GetCurrentIdentityName()}, | ||
}; | ||
} | ||
|
||
private static string GetCurrentIdentityName() | ||
{ | ||
return (Thread.CurrentPrincipal != null && | ||
Thread.CurrentPrincipal.Identity != null && | ||
Thread.CurrentPrincipal.Identity.IsAuthenticated) | ||
? Thread.CurrentPrincipal.Identity.Name | ||
: ""; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.