6
1
mirror of https://git.mills.io/saltyim/saltyim.git synced 2024-07-01 03:01:09 +00:00
prologic-saltyim/internal/exec/errors.go
James Mills 8993981e81 Refactor the code (#38)
Co-authored-by: James Mills <prologic@shortcircuit.net.au>
Reviewed-on: https://git.mills.io/prologic/saltyim/pulls/38
2022-03-21 14:46:16 +00:00

47 lines
764 B
Go

package exec
import (
"fmt"
"syscall"
)
type ErrCommandKilled struct {
Err error
Signal syscall.Signal
}
func (e *ErrCommandKilled) Is(target error) bool {
if _, ok := target.(*ErrCommandKilled); ok {
return true
}
return false
}
func (e *ErrCommandKilled) Error() string {
return fmt.Sprintf("error: command killed: %s", e.Err)
}
func (e *ErrCommandKilled) Unwrap() error {
return e.Err
}
type ErrCommandFailed struct {
Err error
Status int
}
func (e *ErrCommandFailed) Is(target error) bool {
if _, ok := target.(*ErrCommandFailed); ok {
return true
}
return false
}
func (e *ErrCommandFailed) Error() string {
return fmt.Sprintf("error: command failed: %s", e.Err)
}
func (e *ErrCommandFailed) Unwrap() error {
return e.Err
}