enrichHTMLPublishAPIError adapts a typed failure from the HTML publish endpoint: refines endpoint-scoped business codes, prefixes the message with command context, and attaches endpoint-specific recovery hints. A still-untyped error is lifted at the SDK boundary instead.
(err error)
| 79 | // command context, and attaches endpoint-specific recovery hints. A |
| 80 | // still-untyped error is lifted at the SDK boundary instead. |
| 81 | func enrichHTMLPublishAPIError(err error) error { |
| 82 | if err == nil { |
| 83 | return nil |
| 84 | } |
| 85 | p, ok := errs.ProblemOf(err) |
| 86 | if !ok { |
| 87 | return client.WrapDoAPIError(err) |
| 88 | } |
| 89 | // The HTML publish business codes (90001/90002) are scoped to this |
| 90 | // endpoint, not service-global, so their subtype classification lives |
| 91 | // here instead of the global errclass code table. Only an |
| 92 | // otherwise-unclassified API error is refined; a stronger upstream |
| 93 | // classification is never overridden. |
| 94 | if p.Category == errs.CategoryAPI && p.Subtype == errs.SubtypeUnknown && p.Code == errCodeAppNotFound { |
| 95 | p.Subtype = errs.SubtypeNotFound |
| 96 | } |
| 97 | if p.Message != "" { |
| 98 | p.Message = "html-publish failed: " + p.Message |
| 99 | } |
| 100 | if hint := buildHTMLPublishFailureHint(p.Code); hint != "" { |
| 101 | p.Hint = hint |
| 102 | } |
| 103 | return err |
| 104 | } |