MCPcopy
hub / github.com/larksuite/cli / WrapInputStatErrorTyped

Function WrapInputStatErrorTyped

shortcuts/common/runner.go:606–620  ·  view source on GitHub ↗

WrapInputStatErrorTyped wraps a FileIO.Stat/Open error for input file validation, returning a typed validation error with the appropriate message: - Path validation failures → "unsafe file path: ..." - Other errors → readMsg prefix (default "cannot read file") Pass an optional readMsg to override t

(err error, readMsg ...string)

Source from the content-addressed store, hash-verified

604//
605// Pass an optional readMsg to override the non-path-validation message prefix.
606func WrapInputStatErrorTyped(err error, readMsg ...string) error {
607 if err == nil {
608 return nil
609 }
610 if errors.Is(err, fileio.ErrPathValidation) {
611 return errs.NewValidationError(errs.SubtypeInvalidArgument, "unsafe file path: %s", err).
612 WithCause(err)
613 }
614 msg := "cannot read file"
615 if len(readMsg) > 0 && readMsg[0] != "" {
616 msg = readMsg[0]
617 }
618 return errs.NewValidationError(errs.SubtypeInvalidArgument, "%s: %s", msg, err).
619 WithCause(err)
620}
621
622// WrapSaveErrorTyped maps a FileIO.Save error to typed validation/internal errors.
623// Non-path failures always emit the canonical "internal" wire type; call sites

Callers 12

markdownSourceSizeFunction · 0.92
uploadMarkdownFileAllFunction · 0.92
readMarkdownLocalFileFunction · 0.92
uploadImageToIMFunction · 0.92
uploadFileToIMFunction · 0.92
sheetsInputStatErrorFunction · 0.92
wrapDocInputFileErrFunction · 0.92
UploadDriveMediaAllTypedFunction · 0.85

Calls 3

NewValidationErrorFunction · 0.92
IsMethod · 0.80
WithCauseMethod · 0.45