github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/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 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  }