github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/worker/uniter/operation/errors.go (about) 1 // Copyright 2014 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package operation 5 6 import ( 7 "fmt" 8 9 "github.com/juju/errors" 10 corecharm "gopkg.in/juju/charm.v6-unstable" 11 ) 12 13 var ( 14 ErrNoStateFile = errors.New("uniter state file does not exist") 15 ErrSkipExecute = errors.New("operation already executed") 16 ErrNeedsReboot = errors.New("reboot request issued") 17 ErrHookFailed = errors.New("hook failed") 18 ErrCannotAcceptLeadership = errors.New("cannot accept leadership") 19 ) 20 21 type deployConflictError struct { 22 charmURL *corecharm.URL 23 } 24 25 func (err *deployConflictError) Error() string { 26 return fmt.Sprintf("cannot deploy charm %s", err.charmURL) 27 } 28 29 // NewDeployConflictError returns an error indicating that the charm with 30 // the supplied URL failed to deploy. 31 func NewDeployConflictError(charmURL *corecharm.URL) error { 32 return &deployConflictError{charmURL} 33 } 34 35 // IsDeployConflictError returns true if the error is a 36 // deploy conflict error. 37 func IsDeployConflictError(err error) bool { 38 _, ok := err.(*deployConflictError) 39 return ok 40 }