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