formatChangeStepErrorWithHint is like formatChangeStepError but replaces the default suggestion with hint when non-empty, keeping the JSON shape intact.
(err error, defaultCode, permission string, partialRefs map[string]string, hint string)
| 590 | // formatChangeStepErrorWithHint is like formatChangeStepError but replaces the |
| 591 | // default suggestion with hint when non-empty, keeping the JSON shape intact. |
| 592 | func formatChangeStepErrorWithHint(err error, defaultCode, permission string, partialRefs map[string]string, hint string) *mcp.CallToolResult { |
| 593 | var te *toolError |
| 594 | if errors.As(err, &te) && te.Code == "PERMISSION_DENIED" { |
| 595 | return formatChangeError(&changeError{ |
| 596 | Code: "PERMISSION_DENIED", |
| 597 | Message: te.Message, |
| 598 | Suggestion: fmt.Sprintf("ask your workspace admin to grant you the %s permission", permission), |
| 599 | PartialRefs: partialRefs, |
| 600 | }) |
| 601 | } |
| 602 | suggestion := "check the error and retry" |
| 603 | if hint != "" { |
| 604 | suggestion = hint |
| 605 | } |
| 606 | return formatChangeError(&changeError{ |
| 607 | Code: defaultCode, |
| 608 | Message: err.Error(), |
| 609 | Suggestion: suggestion, |
| 610 | PartialRefs: partialRefs, |
| 611 | }) |
| 612 | } |
no test coverage detected