github.com/cloudbase/juju-core@v0.0.0-20140504232958-a7271ac7912f/state/apiserver/testing/errors.go (about)

     1  // Copyright 2013 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package testing
     5  
     6  import (
     7  	"fmt"
     8  
     9  	"launchpad.net/juju-core/state/api/params"
    10  )
    11  
    12  var ErrUnauthorized = &params.Error{
    13  	Message: "permission denied",
    14  	Code:    params.CodeUnauthorized,
    15  }
    16  
    17  func NotFoundError(prefixMessage string) *params.Error {
    18  	return &params.Error{
    19  		Message: fmt.Sprintf("%s not found", prefixMessage),
    20  		Code:    params.CodeNotFound,
    21  	}
    22  }
    23  
    24  func NotProvisionedError(machineId string) *params.Error {
    25  	return &params.Error{
    26  		Message: fmt.Sprintf("machine %s is not provisioned", machineId),
    27  		Code:    params.CodeNotProvisioned,
    28  	}
    29  }
    30  
    31  func NotAssignedError(unitName string) *params.Error {
    32  	return &params.Error{
    33  		Message: fmt.Sprintf("unit %q is not assigned to a machine", unitName),
    34  		Code:    params.CodeNotAssigned,
    35  	}
    36  }
    37  
    38  func ServerError(message string) *params.Error {
    39  	return &params.Error{
    40  		Message: message,
    41  		Code:    "",
    42  	}
    43  }