Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ben Aston
committed
Oct 2, 2011
1 parent
2775515
commit 86250de
Showing
1 changed file
with
36 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,39 @@ | ||
NHelpfulException | ||
==== | ||
|
||
A simple wrapper for System.Exception to help make exceptions more meaningful. | ||
A simple wrapper for System.Exception to help make exceptions more meaningful. | ||
|
||
Usage: | ||
-------- | ||
**1. Create your HelpfulException** | ||
|
||
```C# | ||
|
||
public class MyHelpfulException : HelpfulException | ||
{ | ||
public MyHelpfulException(string problemDescription, | ||
string[] resolutionSuggestions = default(string[]), | ||
Exception innerException = default(Exception)) | ||
: base(problemDescription, resolutionSuggestions, innerException) {} | ||
} | ||
|
||
``` | ||
|
||
**2. Instantiate and throw the exception** | ||
|
||
```C# | ||
|
||
throw new MyHelpfulException("Coffee supply too low.", new []{ "Buy some more coffee.", "Stop drinking so much coffee." }); | ||
|
||
``` | ||
|
||
**3. Bask in the glory of a meaningful exception message | ||
|
||
``` | ||
Coffee supply too low. | ||
Suggestions: | ||
- Buy some more coffee. | ||
- Stop drinking so much coffee. | ||
``` |