diff --git a/cli/azd/pkg/azdext/extension_error.go b/cli/azd/pkg/azdext/extension_error.go index 5c61a00ea5b..1cfb0771321 100644 --- a/cli/azd/pkg/azdext/extension_error.go +++ b/cli/azd/pkg/azdext/extension_error.go @@ -155,5 +155,9 @@ func UnwrapError(msg *ExtensionError) error { } } - return errors.New(msg.GetMessage()) + return &LocalError{ + Message: msg.GetMessage(), + Category: LocalErrorCategoryLocal, + Suggestion: msg.GetSuggestion(), + } } diff --git a/cli/azd/pkg/azdext/extension_error_test.go b/cli/azd/pkg/azdext/extension_error_test.go index 12c7f95ffba..228d33eae6c 100644 --- a/cli/azd/pkg/azdext/extension_error_test.go +++ b/cli/azd/pkg/azdext/extension_error_test.go @@ -33,6 +33,13 @@ func TestExtensionError_RoundTrip(t *testing.T) { assert.Nil(t, protoErr.GetSource()) assert.Equal(t, "simple error", goErr.Error()) + + // Untyped errors round-trip as LocalError so the message is preserved + // through the display and telemetry pipelines. + var localErr *LocalError + require.ErrorAs(t, goErr, &localErr) + assert.Equal(t, "simple error", localErr.Message) + assert.Equal(t, LocalErrorCategoryLocal, localErr.Category) }, }, {