Enhancement to add error code in failure cases
Closed this issue · 2 comments
Dear Vladimir Khorikov,
Thanks for the awesome nuget package. I'm using this widely in my projects. However I got stuck with error code in many of my projects. I needs to send the error code along with the error message, especially in API projects. I'm not able to find a way to send error code along with error message. Hence I though of raising the request.
Existing:
return Result.Failure("Error Message");
It would be great if you could add an overload to the Result.Failure
to take error code with -1 as deafult.
Proposed:
return Result.Failure("Error Message", 10015); // 10015 is error code
Please share your ideas on this.
Thanks,
Abdul Rahman
It's best to create your own Error
class that would encapsulate all info about the error, such as an error code and an error message. You can then use the Result<T,E>
version e.g Result<string, Error>
.
Thanks for the info.