github.com/mhilton/juju-juju@v0.0.0-20150901100907-a94dd2c73455/worker/uniter/runner/errors.go (about) 1 // Copyright 2012-2014 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package runner 5 6 import ( 7 "fmt" 8 9 "github.com/juju/errors" 10 ) 11 12 var ErrRequeueAndReboot = errors.New("reboot now") 13 var ErrReboot = errors.New("reboot after hook") 14 var ErrNoProcess = errors.New("no process to kill") 15 var ErrActionNotAvailable = errors.New("action no longer available") 16 17 type missingHookError struct { 18 hookName string 19 } 20 21 func (e *missingHookError) Error() string { 22 return e.hookName + " does not exist" 23 } 24 25 func IsMissingHookError(err error) bool { 26 _, ok := err.(*missingHookError) 27 return ok 28 } 29 30 func NewMissingHookError(hookName string) error { 31 return &missingHookError{hookName} 32 } 33 34 type badActionError struct { 35 actionName string 36 problem string 37 } 38 39 func (e *badActionError) Error() string { 40 return fmt.Sprintf("cannot run %q action: %s", e.actionName, e.problem) 41 } 42 43 func IsBadActionError(err error) bool { 44 _, ok := err.(*badActionError) 45 return ok 46 } 47 48 func NewBadActionError(actionName, problem string) error { 49 return &badActionError{actionName, problem} 50 }