forked from connamara/quickfixn
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request connamara#740 from rars/improve-authentication-err…
…or-log Capture inner exception messages when handling authentication exceptions
- Loading branch information
Showing
5 changed files
with
56 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
|
||
namespace QuickFix.Util | ||
{ | ||
internal static class ExceptionExtensions | ||
{ | ||
public static string GetFullMessage(this Exception ex) | ||
{ | ||
return ex.InnerException == null | ||
? ex.Message | ||
: ex.Message + " --> " + ex.InnerException.GetFullMessage(); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System; | ||
using NUnit.Framework; | ||
using QuickFix.Util; | ||
|
||
namespace UnitTests.Util | ||
{ | ||
public sealed class ExceptionExtensionsTests | ||
{ | ||
[Test] | ||
public void WhenInnerExceptionShouldReturnJoinedInnerExceptionMessages() | ||
{ | ||
var exception = new Exception( | ||
"Outer exception, see inner exception", | ||
new Exception("My inner exception message")); | ||
|
||
Assert.AreEqual( | ||
exception.GetFullMessage(), | ||
"Outer exception, see inner exception --> My inner exception message"); | ||
} | ||
|
||
[Test] | ||
public void WhenNoInnerExceptionShouldReturnExceptionMessageUnmodified() | ||
{ | ||
var exception = new Exception("My exception message"); | ||
|
||
Assert.AreEqual(exception.GetFullMessage(), "My exception message"); | ||
} | ||
} | ||
} |