You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(slides): emit typed error envelopes across the slides domain
Emit structured validation, API, network, file, and internal error envelopes for Slides shortcuts so users and agents can recover from failed presentation workflows using stable type, subtype, param, and code fields.
Add Slides domain errscontract and golangci guards to prevent legacy envelope and common helper regressions.
returnpresentationRef{}, output.ErrValidation("--presentation cannot be empty")
33
+
returnpresentationRef{}, errs.NewValidationError(errs.SubtypeInvalidArgument, "--presentation cannot be empty").WithParam("--presentation")
34
34
}
35
35
// URL inputs: parse properly and only honor /slides/ or /wiki/ when they
36
36
// appear as a prefix of the URL path. Substring matching previously let
37
37
// e.g. `https://x/docx/foo?next=/slides/abc` resolve to token "abc".
38
38
ifstrings.Contains(raw, "://") {
39
39
u, err:=url.Parse(raw)
40
40
iferr!=nil||u.Path=="" {
41
-
returnpresentationRef{}, output.ErrValidation("unsupported --presentation input %q: use an xml_presentation_id, a /slides/ URL, or a /wiki/ URL", raw)
41
+
returnpresentationRef{}, errs.NewValidationError(errs.SubtypeInvalidArgument, "unsupported --presentation input %q: use an xml_presentation_id, a /slides/ URL, or a /wiki/ URL", raw).WithParam("--presentation")
42
42
}
43
43
iftoken, ok:=tokenAfterPathPrefix(u.Path, "/slides/"); ok {
returnpresentationRef{}, output.ErrValidation("unsupported --presentation input %q: use an xml_presentation_id, a /slides/ URL, or a /wiki/ URL", raw)
49
+
returnpresentationRef{}, errs.NewValidationError(errs.SubtypeInvalidArgument, "unsupported --presentation input %q: use an xml_presentation_id, a /slides/ URL, or a /wiki/ URL", raw).WithParam("--presentation")
50
50
}
51
51
// Non-URL input must be a bare token — anything with path/query/fragment
52
52
// chars is rejected so partial-path inputs like `tmp/wiki/wikcn123` don't
53
53
// get silently accepted.
54
54
ifstrings.ContainsAny(raw, "/?#") {
55
-
returnpresentationRef{}, output.ErrValidation("unsupported --presentation input %q: use an xml_presentation_id, a /slides/ URL, or a /wiki/ URL", raw)
55
+
returnpresentationRef{}, errs.NewValidationError(errs.SubtypeInvalidArgument, "unsupported --presentation input %q: use an xml_presentation_id, a /slides/ URL, or a /wiki/ URL", raw).WithParam("--presentation")
return"", output.Errorf(output.ExitAPI, "api_error", "wiki get_node returned incomplete node data")
98
+
return"", errs.NewInternalError(errs.SubtypeInvalidResponse, "wiki get_node returned incomplete node data")
99
99
}
100
100
ifobjType!="slides" {
101
-
return"", output.ErrValidation("wiki resolved to %q, but slides shortcuts require a slides presentation", objType)
101
+
return"", errs.NewValidationError(errs.SubtypeInvalidArgument, "wiki resolved to %q, but slides shortcuts require a slides presentation", objType).WithParam("--presentation")
returncommon.FlagErrorf("--slides invalid JSON, must be an array of XML strings")
48
+
returnerrs.NewValidationError(errs.SubtypeInvalidArgument, "--slides invalid JSON, must be an array of XML strings").WithParam("--slides")
49
49
}
50
50
iflen(slides) >maxSlidesPerCreate {
51
-
returncommon.FlagErrorf("--slides array exceeds maximum of %d slides; create the presentation first, then add slides via xml_presentation.slide.create", maxSlidesPerCreate)
51
+
returnerrs.NewValidationError(errs.SubtypeInvalidArgument, "--slides array exceeds maximum of %d slides; create the presentation first, then add slides via xml_presentation.slide.create", maxSlidesPerCreate).WithParam("--slides")
52
52
}
53
53
// Validate placeholder paths up front so we don't create a presentation
returntokens, i, fmt.Errorf("@%s: %w", path, err)//nolint:forbidigo // intermediate; preserves typed cause via %w, reclassified by appendSlidesProgressHint at the call site
0 commit comments