2023-03-08 12:20:33 +00:00
|
|
|
namespace InnovEnergy.App.Backend.Utils;
|
2023-02-16 12:57:06 +00:00
|
|
|
|
|
|
|
public class Result
|
|
|
|
{
|
|
|
|
private const String OkMsg = "Ok";
|
|
|
|
|
|
|
|
private readonly String _Error;
|
|
|
|
|
|
|
|
public static Result Ok = new Result(OkMsg);
|
|
|
|
|
|
|
|
public Boolean IsError => _Error != OkMsg;
|
|
|
|
public Boolean IsSuccess => _Error == OkMsg;
|
|
|
|
|
|
|
|
private Result(String error) => _Error = error;
|
|
|
|
|
|
|
|
public static Result Error(String error) => new Result(error);
|
|
|
|
|
|
|
|
public static Result Error(Exception exception)
|
|
|
|
{
|
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
var msg = exception.ToString(); // includes stacktrace
|
|
|
|
#else
|
|
|
|
var msg = exception.Message; // excludes stacktrace
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return new Result(msg);
|
|
|
|
}
|
|
|
|
}
|