-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror.go
More file actions
36 lines (30 loc) · 1.39 KB
/
Copy patherror.go
File metadata and controls
36 lines (30 loc) · 1.39 KB
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
31
32
33
34
35
36
package gloo
import (
"strconv"
errs "github.com/gomatic/go-error"
)
// Error is the framework's sentinel-error type — an alias of [errs.Const] from
// github.com/gomatic/go-error, which owns the mechanism (Error, With). The
// alias exists for hub compatibility: the fleet of cmd-* consumers declares
// sentinels as consts of this type (const ErrX gloo.Error = "...") and wraps
// with .With(cause, args...); because an alias is the same type, every such
// declaration, .With call, and errors.Is match keeps compiling and behaving
// identically. New code may use errs.Const directly.
type Error = errs.Const
// ExitStatus is an error carrying a process-style exit status, completing the
// Unix contract's second half: a tool like grep signals "no match" with exit 1
// — a status, not a diagnostic. A command emits it on its stream
// (sendErr(gloo.ExitStatus(1))); a binary wrapper extracts it with errors.As
// and passes Status() to os.Exit instead of printing it as a failure.
//
// It is a comparable value type, so errors.Is(err, gloo.ExitStatus(1)) matches
// exactly and distinct statuses stay distinct.
type ExitStatus int
// Error renders the conventional shell description of the status.
func (e ExitStatus) Error() string {
return "exit status " + strconv.Itoa(int(e))
}
// Status is the numeric exit status for a wrapper to hand to os.Exit.
func (e ExitStatus) Status() int {
return int(e)
}