Skip to content

Commit 7e68f1a

Browse files
committed
refactor
1 parent 2b98309 commit 7e68f1a

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

internal/provider/action_local_command.go

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,14 @@ func (a *localCommandAction) Invoke(ctx context.Context, req action.InvokeReques
135135
return
136136
}
137137

138-
resp.Diagnostics.Append(genericCommandDiag(cmd, err))
138+
resp.Diagnostics.AddAttributeError(
139+
path.Root("command"),
140+
"Command Execution Failed",
141+
"The action received an unexpected error while attempting to execute the command."+
142+
"\n\n"+
143+
fmt.Sprintf("Command: %s\n", cmd.Path)+
144+
fmt.Sprintf("Error: %s", err),
145+
)
139146
return
140147
}
141148

@@ -177,14 +184,3 @@ func findCommand(command string) diag.Diagnostic {
177184

178185
return nil
179186
}
180-
181-
func genericCommandDiag(cmd *exec.Cmd, err error) diag.Diagnostic {
182-
return diag.NewAttributeErrorDiagnostic(
183-
path.Root("command"),
184-
"Command Execution Failed",
185-
"The action received an unexpected error while attempting to execute the command."+
186-
"\n\n"+
187-
fmt.Sprintf("Command: %s\n", cmd.Path)+
188-
fmt.Sprintf("Error: %s", err),
189-
)
190-
}

0 commit comments

Comments
 (0)