chore: import upstream snapshot with attribution
CI / license-header (push) Has been skipped
CI / e2e-dry-run (push) Has been skipped
CI / fast-gate (push) Failing after 0s
Test PR Label Logic / test-pr-labels (push) Failing after 1s
Skill Format Check / check-format (push) Failing after 2s
CI / security (push) Failing after 5s
CI / unit-test (push) Has been skipped
CI / lint (push) Has been skipped
CI / script-test (push) Has been skipped
CI / deterministic-gate (push) Has been skipped
CI / coverage (push) Has been skipped
CI / results (push) Has been cancelled
CI / deadcode (push) Has been cancelled
CI / e2e-live (push) Has been cancelled
CI / license-header (push) Has been skipped
CI / e2e-dry-run (push) Has been skipped
CI / fast-gate (push) Failing after 0s
Test PR Label Logic / test-pr-labels (push) Failing after 1s
Skill Format Check / check-format (push) Failing after 2s
CI / security (push) Failing after 5s
CI / unit-test (push) Has been skipped
CI / lint (push) Has been skipped
CI / script-test (push) Has been skipped
CI / deterministic-gate (push) Has been skipped
CI / coverage (push) Has been skipped
CI / results (push) Has been cancelled
CI / deadcode (push) Has been cancelled
CI / e2e-live (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
// Copyright (c) 2026 Lark Technologies Pte. Ltd.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package markdown
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/larksuite/cli/errs"
|
||||
)
|
||||
|
||||
func markdownValidationError(format string, args ...any) *errs.ValidationError {
|
||||
return errs.NewValidationError(errs.SubtypeInvalidArgument, format, args...)
|
||||
}
|
||||
|
||||
func markdownValidationParamError(param, format string, args ...any) *errs.ValidationError {
|
||||
return markdownValidationError(format, args...).WithParam(param)
|
||||
}
|
||||
|
||||
func markdownInvalidParam(name, reason string) errs.InvalidParam {
|
||||
return errs.InvalidParam{Name: name, Reason: reason}
|
||||
}
|
||||
|
||||
// withMarkdownFileParam tags a validation failure with the originating flag
|
||||
// when it does not already name one. Shared input-file helpers such as
|
||||
// common.WrapInputStatErrorTyped cannot know which flag supplied the path, so
|
||||
// the caller attaches it here to keep the recoverable param on the wire.
|
||||
func withMarkdownFileParam(err error, param string) error {
|
||||
if err == nil || param == "" {
|
||||
return err
|
||||
}
|
||||
var ve *errs.ValidationError
|
||||
if errors.As(err, &ve) && ve.Param == "" {
|
||||
ve.WithParam(param)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// 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.
|
||||
// An untyped error becomes a network transport error carrying the original as
|
||||
// its cause.
|
||||
func wrapMarkdownDownloadError(err error) error {
|
||||
if p, ok := errs.ProblemOf(err); ok {
|
||||
if p.Category != errs.CategoryValidation {
|
||||
p.Message = "download failed: " + p.Message
|
||||
}
|
||||
return err
|
||||
}
|
||||
return errs.NewNetworkError(errs.SubtypeNetworkTransport, "download failed: %s", err).WithCause(err)
|
||||
}
|
||||
Reference in New Issue
Block a user