Debian Codegraph @

moreinterp/coreutils/error.go

raw
1 package coreutils
2
3 import (
4 "fmt"
5
6 "mvdan.cc/sh/v3/interp"
7 )
8
9 // Error wraps any error returned from the core utilities.
10 // It unwraps to an exit status of 1 so that a failing command results in
11 // a regular non-zero exit status rather than a fatal error.
12 type Error struct {
13 err error
14 }
15
16 var (
17 _ error = &Error{}
18 _ interface{ Unwrap() []error } = &Error{}
19 )
20
21 func (err *Error) Error() string {
22 return fmt.Sprintf("coreutils: %v", err.err)
23 }
24
25 func (err *Error) Unwrap() []error {
26 return []error{err.err, interp.NewExitStatus(1)}
27 }