Here is a typical function that returns true / false;
private static bool hasValue()
{
return true;
}
Now on error, I would like to return my own error object with the definition:
public class Failure
{
public string FailureDateTime { get; set; }
public string FailureReason { get; set; }
}
I would expect you to be able to cast this custom object like ...
private static bool hasValue()
{
try
{
...do something
}
catch
{
throw new Failure();
}
return true;
}
This is not possible, and I do not want to throw Failure from System.IO.Exception, because I personally had problems with serializing exceptions in C # (this was with .net v2).
What is the best practice or perfect solution to this problem. Should I just work with a private static object? Or is there a cleaner way to return a custom object or bypass a typical return type on error (without using System.IO.Exception)?
, , casting more boolean.