Result type for operations that may fail, with explicit cancellation tracking
on the failure branch.
The framework-wide convention:
APIs that ask a single question (pick, input, notifications) return
T | undefined, matching VS Code's own vocabulary where undefined means
the user dismissed the prompt.
APIs that perform fallible work and want to report why return a Result.
cancelled exists so a caller can tell "the user backed out" apart from "this
failed", without inspecting the error. Collapsing the two is the mistake this
type is here to prevent.
Type Parameters
T
E = Error
Example
constresult = awaittryRefresh(); if (!result.ok) { if (result.cancelled) return; logger.error('refresh failed', result.error); return; } use(result.value);
Result type for operations that may fail, with explicit cancellation tracking on the failure branch.
The framework-wide convention:
T | undefined, matching VS Code's own vocabulary whereundefinedmeans the user dismissed the prompt.Result.cancelledexists so a caller can tell "the user backed out" apart from "this failed", without inspecting the error. Collapsing the two is the mistake this type is here to prevent.