Artifact 96a72bf43e140df4ebd5c50be6cb54a99eea7a4ec04cb3187b040f42ee6f6e3a:
- File
errors.go
— part of check-in
[7eb46a9635]
at
2026-04-26 15:00:12
on branch trunk
— feat(repo): expose ResolveVersion + ReadFileAt for symbolic versions (#11)
* feat(repo): expose ResolveVersion + ReadFileAt for symbolic versions
Repo.ReadFile took a raw int64 RID, leaving every library caller to re-implement symbolic-version resolution (tip, trunk, branch name, UUID prefix) — work the CLI's resolveRID already does inside the cli package. Move the resolver onto Repo as ResolveVersion, refactor cli/shared.go to call it, and add Repo.ReadFileAt(version, path) so callers can read by name without first calling ResolveVersion themselves.
Adds ErrVersionNotFound for the not-found case and an ambiguity error for prefix collisions.
* chore(cli): drop unused openInternalRepo helper + repo import
Now-dead code: resolveRID was its only caller, and resolveRID is now a one-line wrapper around Repo.ResolveVersion that doesn't need the inner handle. Also removes the now-unused internal/repo import that the helper brought in, and refreshes the cli SDK page accordingly.
* chore(go.work.sum): pin transitive deps from docs toolchain
gomarkdoc pulls these via go install during make docs-gen-sdk; commit the lockfile entries so contributors see no go.work.sum drift after a docs build. (user: [email protected], size: 2394) [annotate] [blame] [check-ins using]
package libfossil import ( "errors" "fmt" ) type RC int const ( RCOK RC = 0 RCError RC = 100 RCNYI RC = 101 RCOOM RC = 102 RCMisuse RC = 103 RCRange RC = 104 RCAccess RC = 105 RCIO RC = 106 RCNotFound RC = 107 RCAlreadyExists RC = 108 RCConsistency RC = 109 RCRepoNeedsRebuild RC = 110 RCNotARepo RC = 111 RCRepoVersion RC = 112 RCDB RC = 113 RCBreak RC = 114 RCStepRow RC = 115 RCStepDone RC = 116 RCStepError RC = 117 RCType RC = 118 RCNotACkout RC = 119 RCRepoMismatch RC = 120 RCChecksumMismatch RC = 121 RCLocked RC = 122 RCConflict RC = 123 RCSizeMismatch RC = 124 RCPhantom RC = 125 RCUnsupported RC = 126 ) var rcNames = map[RC]string{ RCOK: "ok", RCError: "error", RCNYI: "nyi", RCOOM: "oom", RCMisuse: "misuse", RCRange: "range", RCAccess: "access", RCIO: "io", RCNotFound: "not_found", RCAlreadyExists: "already_exists", RCConsistency: "consistency", RCRepoNeedsRebuild: "repo_needs_rebuild", RCNotARepo: "not_a_repo", RCRepoVersion: "repo_version", RCDB: "db", RCBreak: "break", RCStepRow: "step_row", RCStepDone: "step_done", RCStepError: "step_error", RCType: "type", RCNotACkout: "not_a_ckout", RCRepoMismatch: "repo_mismatch", RCChecksumMismatch: "checksum_mismatch", RCLocked: "locked", RCConflict: "conflict", RCSizeMismatch: "size_mismatch", RCPhantom: "phantom", RCUnsupported: "unsupported", } func (rc RC) String() string { if s, ok := rcNames[rc]; ok { return s } return fmt.Sprintf("rc_%d", int(rc)) } type FslError struct { Code RC Msg string Cause error } func (e *FslError) Error() string { return fmt.Sprintf("fossil(%s): %s", e.Code, e.Msg) } func (e *FslError) Unwrap() error { return e.Cause } // ErrVersionNotFound is returned by ResolveVersion when the requested version // string does not match any artifact in the repository. Callers can match // with errors.Is. var ErrVersionNotFound = errors.New("libfossil: version not found") // ErrAmbiguousVersion is returned by ResolveVersion when a UUID prefix // matches more than one artifact (collision). Callers can match with // errors.Is. var ErrAmbiguousVersion = errors.New("libfossil: ambiguous version prefix")