public async Task <IActionResult> Status()
        {
            try
            {
                using CommandConnection connection = await BuildConnection();

                string machineModel = await connection.GetSerializedObjectModel();

                return(Content(machineModel, "application/json"));
            }
            catch (Exception e)
            {
                if (e is AggregateException ae)
                {
                    e = ae.InnerException;
                }
                if (e is IncompatibleVersionException)
                {
                    _logger.LogError($"[{nameof(Status)}] Incompatible DCS version");
                    return(StatusCode(502, "Incompatible DCS version"));
                }
                if (e is SocketException)
                {
                    _logger.LogError($"[{nameof(Status)}] DCS is not started");
                    return(StatusCode(503, "Failed to connect to Duet, please check your connection (DCS is not started)"));
                }
                _logger.LogWarning(e, $"[{nameof(Status)}] Failed to retrieve status");
                return(StatusCode(500, e.Message));
            }
        }