-
Notifications
You must be signed in to change notification settings - Fork 563
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Capture inner exception messages in log output when handling authenti…
…cation exceptions pr #740
- Loading branch information
1 parent
39d101e
commit d355ffb
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"); | ||
} | ||
} | ||
} |