-
Notifications
You must be signed in to change notification settings - Fork 783
/
errors.go
36 lines (28 loc) · 830 Bytes
/
errors.go
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
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package manager
import "fmt"
// ErrExitable is an interface that defines an integer ExitStatus() function.
type ErrExitable interface {
ExitStatus() int
}
var (
_ error = new(ErrChildDied)
_ ErrExitable = new(ErrChildDied)
)
// ErrChildDied is the error returned when the child process prematurely dies.
type ErrChildDied struct {
code int
}
// NewErrChildDied creates a new error with the given exit code.
func NewErrChildDied(c int) *ErrChildDied {
return &ErrChildDied{code: c}
}
// Error implements the error interface.
func (e *ErrChildDied) Error() string {
return fmt.Sprintf("child process exited with code %d", e.code)
}
// ExitStatus implements the ErrExitable interface.
func (e *ErrChildDied) ExitStatus() int {
return e.code
}