From deb941a21684428e5751b0d6dc5fa5dca5b42fb3 Mon Sep 17 00:00:00 2001 From: Vitaly Antonenko Date: Thu, 29 Feb 2024 15:16:39 +0300 Subject: [PATCH] Adds error check to ReadModel fucntion. This commit adds missed error check aftert we get models. This fix will help to avoid stack trace in some cases. --- internal/juju/models.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/juju/models.go b/internal/juju/models.go index 60a2dc59..cff08caf 100644 --- a/internal/juju/models.go +++ b/internal/juju/models.go @@ -232,6 +232,10 @@ func (c *modelsClient) ReadModel(name string) (*ReadModelResponse, error) { return nil, &modelNotFoundError{uuid: modelUUIDTag.Id()} } + // Check if the model has an error first + if models[0].Error != nil { + return nil, models[0].Error + } modelInfo := *models[0].Result modelConfig, err := modelconfigClient.ModelGet()