wrapMarkdownDownloadError classifies a download failure. An already-typed error keeps its carrier — type, subtype, code and extensions — so callers see the upstream classification: a validation problem passes through verbatim, any other problem gains a "download failed" prefix for operation context.
(err error)
| 43 | // An untyped error becomes a network transport error carrying the original as |
| 44 | // its cause. |
| 45 | func wrapMarkdownDownloadError(err error) error { |
| 46 | if p, ok := errs.ProblemOf(err); ok { |
| 47 | if p.Category != errs.CategoryValidation { |
| 48 | p.Message = "download failed: " + p.Message |
| 49 | } |
| 50 | return err |
| 51 | } |
| 52 | return errs.NewNetworkError(errs.SubtypeNetworkTransport, "download failed: %s", err).WithCause(err) |
| 53 | } |