public static Ret <Entity> Create(Route route, HttpStatusCode status, string message, Exception exception) { var causes = EnumerateCauses(message, exception).Distinct(); var description = causes.Any() ? string.Join(Environment.NewLine, causes) : null; var entity = new Entity(); entity.Class = KnownClasses.Status; if ((int)status >= 400) { entity.Class.Add(KnownClasses.Error); } entity.Properties = new PropertyCollection(); entity.Properties.Add("Code", (int)status); entity.Properties.Add("Status", status.ToString()); if (description != null) { entity.Properties.Add("Description", description); } if (exception != null) { entity.Properties.Add("StackTrace", exception.GetStackTrace()); } entity.Links = new LinkCollection(); entity.Links.Add(new Link { Href = route.ToString(), Rel = KnownRelations.Self }); return(Ret.As(status, entity)); }