public static HealthCheckResponse CreateFrom(HealthReport report) { var uiReport = new HealthCheckResponse(new Dictionary <string, HealthReportEntry>(), report.TotalDuration) { Status = (HealthStatus)report.Status, }; foreach (var item in report.Entries) { var entry = new HealthReportEntry { Data = item.Value.Data, Description = item.Value.Description, Duration = item.Value.Duration, Status = (HealthStatus)item.Value.Status }; if (item.Value.Exception != null) { var message = item.Value.Exception? .Message .ToString(); entry.Exception = message; entry.Description = item.Value.Description ?? message; } uiReport.Entries.Add(item.Key, entry); } return(uiReport); }
public static HealthCheckResponse CreateFrom(Exception exception, string entryName = "Endpoint") { var uiReport = new HealthCheckResponse(new Dictionary <string, HealthReportEntry>(), TimeSpan.FromSeconds(0)) { Status = HealthStatus.Unhealthy, }; uiReport.Entries.Add(entryName, new HealthReportEntry { Exception = exception.Message, Description = exception.Message, Duration = TimeSpan.FromSeconds(0), Status = HealthStatus.Unhealthy }); return(uiReport); }