public async Task <IActionResult> Status() { try { using CommandConnection connection = await BuildConnection(); MemoryStream json = await connection.GetSerializedMachineModel(); if (json != null) { return(new FileStreamResult(json, "application/json")); } return(new NoContentResult()); } catch (AggregateException ae) when(ae.InnerException is IncompatibleVersionException) { _logger.LogError($"[{nameof(Status)}] Incompatible DCS version"); return(StatusCode(502, ae.InnerException.Message)); } catch (AggregateException ae) when(ae.InnerException is SocketException) { _logger.LogError($"[{nameof(Status)}] DCS is unavailable"); return(StatusCode(503, ae.InnerException.Message)); } catch (Exception e) { _logger.LogWarning(e, $"[{nameof(Status)}] Failed to retrieve status"); return(StatusCode(500, e.Message)); } }