// ExitStatus queries the error for an exit status.  If the error is nil, it
// returns 0.  If the error does not implement ExitStatus() int, it returns 1.
// Otherwise it retiurns the value from ExitStatus().
432568
func ExitStatus(err error) int {
	if err == nil {
		return 0
	}
	exit, ok := err.(exitStatus)
	if !ok {
		return 1
	}
	return exit.ExitStatus()
}
1087127
func (c *Cmd) GetExitCode() {

	c.ExitCode = 1

	if c.ExitError != nil {
		if c.Cmd.ProcessState != nil {
			if status, ok := c.Cmd.ProcessState.Sys().(syscall.WaitStatus); ok {
				c.ExitCode = status.ExitStatus()
			}
		}
	} else {
		c.ExitCode = 0
	}
}
1139245
func errorStatus(err error) uint32 {
	if x, ok := err.(*Status); ok {
		return x.Code
	}

	switch {
	case os.IsNotExist(err):
		return StatusNoSuchFileOrDir
	case os.IsExist(err):
		return StatusFileExists
	case os.IsPermission(err):
		return StatusOperationNotPermitted
	}

	return StatusGenericError
}
377399
func CheckErrorStatus(code int, res *http.Response) error {
	err := CheckError(res)
	if err != nil {
		return err
	}

	if res.StatusCode != code {
		return fmt.Errorf("unexpected status code: %s", res.Status)
	}

	return nil
}
1307040
func ErrorToWaitStatus(err error) (syscall.WaitStatus, bool) {
	if e, ok := err.(*exec.ExitError); ok {
		st, ok := e.Sys().(syscall.WaitStatus)
		return st, ok
	}
	var zero syscall.WaitStatus
	return zero, false
}
937226
func ExpectStatus(t T, r *http.Response, status int) bool {
	if r == nil {
		logerror(t, serrorf("ExpectStatus: got nil but want Http response"))
		return false
	}
	if r.StatusCode != status {
		if verboseOnFailure {
			Dump(t, r)
		}
		logfatal(t, serrorf("ExpectStatus: got status %d but want %d, %s %v", r.StatusCode, status, r.Request.Method, r.Request.URL))
		return false
	}
	return true
}
386621
func CheckStatus(r *HttpResponse, err error) (*HttpResponse, error) {
	if err != nil {
		return r, err
	}

	return r, r.ResponseError()
}
227336
func (e Entry) Status() Status {
	switch v := e[statusKey].(type) {
	case string:
		return Status(v)
	case Status:
		return v
	default:
		panic(fmt.Sprintf("invalid status: %v", v))
	}
}
590191
func (e *Evaluation) TerminalStatus() bool {
	switch e.Status {
	case EvalStatusComplete, EvalStatusFailed, EvalStatusCancelled:
		return true
	default:
		return false
	}
}
603138
func (i *Import) GetStatus() string {
	if i == nil || i.Status == nil {
		return ""
	}
	return *i.Status
}
1277924
func UserErrorFromStatus(s keybase1.StatusCode) error {
	switch s {
	case keybase1.StatusCode_SCOk:
		return nil
	case keybase1.StatusCode_SCDeleted:
		return UserDeletedError{}
	default:
		return &APIError{Code: int(s), Msg: "user status error"}
	}
}
134507
func Exitf(format string, args ...interface{}) {
	Global.intLogf(ERROR, format, args...)
	Global.Close() // so that hopefully the messages get logged
	os.Exit(0)
}
314670
func (rp *Reply) StatusValue() (string, error) {
	if rp.Type == ErrorReply {
		return "", errors.New(rp.Error)
	}
	if rp.Type != StatusReply {
		return "", errors.New("invalid reply type, not status")
	}
	return rp.Status, nil
}
1238384
func (m *MockMachineProvisioner) InstanceStatus() (status.Status, string, error) {
	ret := m.ctrl.Call(m, "InstanceStatus")
	ret0, _ := ret[0].(status.Status)
	ret1, _ := ret[1].(string)
	ret2, _ := ret[2].(error)
	return ret0, ret1, ret2
}
1018497
func (ctx *Context) ErrorStatus(status int) error {
	if status >= 400 && IsStatusCode(status) {
		return ctx.Error(ErrByStatus(status))
	}
	return ErrInternalServerError.WithMsg("invalid error status")
}
314187
func (c *FakeClient) ReleaseStatus(rlsName string, opts ...StatusOption) (*rls.GetReleaseStatusResponse, error) {
	for _, rel := range c.Rels {
		if rel.Name == rlsName {
			return &rls.GetReleaseStatusResponse{
				Name:      rel.Name,
				Info:      rel.Info,
				Namespace: rel.Namespace,
			}, nil
		}
	}
	return nil, storageerrors.ErrReleaseNotFound(rlsName)
}
886927
func (s *SetStatusInput) SetStatus(v string) *SetStatusInput {
	s.Status = &v
	return s
}