A Better Exception for .NET
This simple library is engineered to expose a new API for the standard .NET Exception
model to allow upserting a list of values against a key in the Data
property of that very exception.
The purpose of this library is to allow .NET engineers to easily collect errors for any given flow or attribute before throwing the exception.
This new API simplifies the process of appending and being able to access the Data
aspect of any exception to collect errors at any point in time.
The key value implementation for the Data
attribute should make it simpler for engineers to represent errors around the same issue, attribute or value such as validation errors easily without any additional work-around code.
To use Xeption; all you need to do is to inherit the Xeption
model to your local Exception models as follows:
public class MyLocalException: Xeption
{
// ...
}
To add values to your Xeption
inheriting class, you will need to call .UpsertDataList(key, value)
API to add more values to the dictionary as follows:
var myLocalException = new MyLocalException();
myLocalException.UpsertDataList(key: "MyKey", value: "MyValue");
Xeption also provides the ability to throw the local exception iff the data dictionary contains values in it. You can simply call that API from your local instance as follows:
myLocalException.ThrowIfContainsErrors();
Xeption will maintain the native APIs for the Exception
native class.
var xeption = new Xeption();
var xeptionWithMessage = new Xeption(message: "Some Message");
var xeptionWithInnerException = new Xeption(
message: "Some Message",
innerException: someInnerException);
If you have any suggestions, comments or questions, please feel free to contact me on:
Twitter: @hassanrezkhabib
LinkedIn: hassanrezkhabib
E-Mail: [email protected]