public static RetFault Throw(IRet ret) { return(new RetFault { Status = ret.Status, Fault = ret.Fault }); }
public static Ret <Entity> CreateFromRet(Route route, IRet ret) { if (ret.Data is Entity) { return((Entity)ret.Data); } return(Create(route, ret.Status, ret.GetMessage(), ret.GetException())); }
public static string GetMessage(this IRet ret) { var ex = ret.Fault as Exception; if (ex != null) { var message = ex.Message; while (ex.InnerException != null) { ex = ex.InnerException; message += "\n" + ex.Message; } return(message); } else { return(ret.Fault?.ToString()); } }
public static Exception GetException(this IRet ret) => ret.Fault as Exception;
public static bool IsNotFoundOrImplemented(this IRet ret) => ret.Status == (int)HttpStatusCode.NotFound || ret.Status == (int)HttpStatusCode.NotImplemented;
public static bool IsNotFound(this IRet ret) => ret.Status == (int)HttpStatusCode.NotFound;
public static bool IsFault(this IRet ret) => ret.Status >= 400;
public static bool IsOk(this IRet ret) => ret.Status < 400;