~bigbes/sr-ht-compare

ref: 9473e2606cd90cb8d3b78ee87511c671157439f4 sr-ht-compare/core/errors.go -rw-r--r-- 1.3 KiB
9473e260 — bigbes gitx: repository access and ref-to-ref diffs on go-git a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Package core holds the pure domain logic of compare.sr.ht: input
// validation (owner/repo/ref names), the compare-spec grammar, and the
// sentinel errors shared across the service. It has no external dependencies
// and never touches the network or the filesystem, so it is cheap to test.
package core

import "errors"

// Sentinel errors. Callers compare with errors.Is; wrapping with %w adds
// human-readable detail without losing the class.
var (
	// ErrNotFound is returned when a repo, ref, or object does not exist —
	// or, for authorization, when the viewer is not allowed to know it
	// exists. Handlers map this to HTTP 404 (never 403, so private-repo
	// existence is not leaked).
	ErrNotFound = errors.New("not found")

	// ErrForbidden marks an operation the viewer is authenticated for but
	// not permitted to perform. Repo visibility deliberately uses
	// ErrNotFound instead; ErrForbidden is reserved for genuine 403 cases.
	ErrForbidden = errors.New("forbidden")

	// ErrBadRef is returned for malformed compare specs or refs that fail
	// check-ref-format validation. Handlers map this to HTTP 400.
	ErrBadRef = errors.New("invalid git ref")

	// ErrTruncated signals that git output exceeded the in-page size cap.
	// The handler renders the file list plus a link to the raw .patch.
	ErrTruncated = errors.New("output truncated")
)