From ff3d320c18973c5cd9c4cc30d3a5478bd1443003 Mon Sep 17 00:00:00 2001 From: Peter Sprygada Date: Mon, 17 Mar 2025 21:29:30 -0400 Subject: [PATCH] display a more verbose error when importing a model When importing a model, the application will check to see if the workflow, pre and post transformations exist for every action defined in the model. It will return an error to the user if any one of the dependencies does not exist. The returned messages in some cases is fairly generic. The application will now return a more verbose error message to indidcate which action the dependency failed to find prior to importing the model. fixes #67 --- internal/runners/models.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/internal/runners/models.go b/internal/runners/models.go index 8d9800a9..6ebb919b 100644 --- a/internal/runners/models.go +++ b/internal/runners/models.go @@ -525,7 +525,9 @@ func (r *ModelRunner) importActionMap(action map[string]interface{}, path string if !skipChecks { wf, err := services.NewWorkflowService(r.client).Get(value.(string)) if err != nil { - return err + return errors.New( + fmt.Sprintf("workflow for action `%s` encountered the following error: %s", action["name"], err.Error()), + ) } if wf != nil { return errors.New( @@ -551,7 +553,9 @@ func (r *ModelRunner) importActionMap(action map[string]interface{}, path string var res *services.Transformation res, err := services.NewTransformationService(r.client).Get(value.(string)) if err != nil { - return err + return errors.New( + fmt.Sprintf("pre transformation for action `%s` encountered the following error: %s", action["name"], err.Error()), + ) } if res != nil { return errors.New( @@ -577,7 +581,9 @@ func (r *ModelRunner) importActionMap(action map[string]interface{}, path string var res *services.Transformation res, err := services.NewTransformationService(r.client).Get(value.(string)) if err != nil { - return err + return errors.New( + fmt.Sprintf("post transformation for action `%s` encountered the following error: %s", action["name"], err.Error()), + ) } if res != nil { return errors.New( @@ -597,7 +603,6 @@ func (r *ModelRunner) importActionMap(action map[string]interface{}, path string } delete(action, "postWorkflowjstFilename") action["postWorkflowJst"] = res.Id - } return nil