github.com/mhilton/juju-juju@v0.0.0-20150901100907-a94dd2c73455/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.v5" 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 // DeployConflictCharmURL returns the charm URL used to create the supplied 36 // deploy conflict error, and a bool indicating success. 37 func DeployConflictCharmURL(err error) (*corecharm.URL, bool) { 38 if e, ok := err.(*deployConflictError); ok { 39 return e.charmURL, true 40 } 41 return nil, false 42 }