diff --git a/shortcuts/application/slash_command_create.go b/shortcuts/application/slash_command_create.go index b1691a38f..2d0bc193f 100644 --- a/shortcuts/application/slash_command_create.go +++ b/shortcuts/application/slash_command_create.go @@ -82,7 +82,8 @@ var SlashCommandCreate = common.Shortcut{ if !runtime.Bool("force") { p, _ := errs.ProblemOf(err) rewrapped := errs.NewAPIError(p.Subtype, "slash command %q already exists", name). - WithHint("rerun with --force to update it, or use `lark-cli application +slash-command-update --command %q`", name) + WithHint("rerun with --force to update it, or use `lark-cli application +slash-command-update --command %q`", name). + WithCause(err) if p.Code != 0 { rewrapped = rewrapped.WithCode(p.Code) } diff --git a/shortcuts/application/slash_command_create_test.go b/shortcuts/application/slash_command_create_test.go index 02d0e7c0b..7a262e35f 100644 --- a/shortcuts/application/slash_command_create_test.go +++ b/shortcuts/application/slash_command_create_test.go @@ -5,6 +5,7 @@ package application import ( "encoding/json" + "errors" "strings" "testing" @@ -103,6 +104,13 @@ func TestSlashCommandCreate_ConflictNoForce(t *testing.T) { if !strings.Contains(p.Hint, "--force") || !strings.Contains(p.Hint, "+slash-command-update") { t.Fatalf("hint must offer --force and update, got %q", p.Hint) } + var apiErr *errs.APIError + if !errors.As(err, &apiErr) { + t.Fatalf("rewrapped error must be *errs.APIError, got %T", err) + } + if errors.Unwrap(apiErr) == nil { + t.Fatal("rewrapped conflict error must preserve the original cause via WithCause") + } } func TestSlashCommandCreate_ForceConvertsToUpdate(t *testing.T) {