// ToStatus implements the ExportableError interface for ServerErrorNonceNonExistent
492587
func (e ServerErrorNonceNonExistent) ToStatus() (s keybase1.Status) {
	s.Code = StatusCodeServerErrorNonceNonExistent
	s.Name = "BLOCK_NONCENONEXISTENT"
	s.Desc = e.Msg
	return
}
276774
func ToStatus(err *platform.Error) (*status.Status, error) {
	if err == nil {
		return status.New(codes.OK, ""), nil
	}

	c := codes.Unknown
	switch err.Code {
	case platform.EInternal:
		c = codes.Internal
	case platform.ENotFound, platform.EMethodNotAllowed:
		c = codes.NotFound
	case platform.EConflict, platform.EInvalid, platform.EEmptyValue: // not really sure how to express this as gRPC only has Invalid
		c = codes.InvalidArgument
	case platform.EUnavailable:
		c = codes.Unavailable
	}

	buf, jerr := json.Marshal(err)
	if jerr != nil {
		return nil, jerr
	}

	return status.New(c, string(buf)), nil
}
1101810
func (e ServerErrorConflictDiskUsage) ToStatus() (s keybase1.Status) {
	s.Code = StatusCodeServerErrorConflictDiskUsage
	s.Name = "CONFLICT_DISK_USAGE"
	s.Desc = e.Error()
	return
}
363006
func (se *statusError) GRPCStatus() *status.Status {
	p := (*rpc.Status)(se)
	s := &spb.Status{
		Code:    p.GetCode(),
		Message: p.GetMessage(),
	}
	for _, detail := range p.GetDetails() {
		s.Details = append(s.GetDetails(), &any.Any{
			TypeUrl: detail.GetTypeUrl(),
			Value:   detail.GetValue(),
		})
	}
	return status.FromProto(s)
}
1218624
func (ar *allocRunner) SetClientStatus(clientStatus string) {
	ar.stateLock.Lock()
	defer ar.stateLock.Unlock()
	ar.state.ClientStatus = clientStatus
}
1128573
func (client *Client) DeleteRunstatusMaintenance(ctx context.Context, maintenance RunstatusMaintenance) error {
	if maintenance.URL == "" {
		return fmt.Errorf("empty URL for %#v", maintenance)
	}

	_, err := client.runstatusRequest(ctx, maintenance.URL, nil, "DELETE")
	return err
}
124976
func (c *Connection) IndexStatus(indexList []string) (*Response, error) {
	r := Request{
		Conn:      c,
		IndexList: indexList,
		method:    "GET",
		api:       "_status",
	}

	return r.Run()
}
863513
func (e APINetError) ToStatus() (s keybase1.Status) {
	s.Code = SCAPINetworkError
	s.Name = "API_NETWORK_ERROR"
	s.Desc = e.Error()
	return
}
1027486
func CheckErrorStatus(code int, res *http.Response, isPlatformError ...bool) error {
	err := CheckError(res)
	if len(isPlatformError) > 0 && isPlatformError[0] {
		err = CheckError(res, true)
	}
	if err != nil {
		return err
	}

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

	return nil
}
434756
func (s *SimpleFSHandler) SimpleFSSyncStatus(ctx context.Context, filter keybase1.ListFilter) (keybase1.FSSyncStatus, error) {
	ctx, cancel := s.wrapContextWithTimeout(ctx)
	defer cancel()
	cli, err := s.client()
	if err != nil {
		return keybase1.FSSyncStatus{}, err
	}
	return cli.SimpleFSSyncStatus(ctx, filter)
}
803204
func osStatusError(s C.OSStatus) error {
	if s == C.errSecSuccess {
		return nil
	}

	return osStatus(s)
}
965259
func (e NeedSelfRekeyError) ToStatus() keybase1.Status {
	kv := keybase1.StringKVPair{
		Key:   "Tlf",
		Value: string(e.Tlf),
	}
	return keybase1.Status{
		Code:   int(keybase1.StatusCode_SCNeedSelfRekey),
		Name:   "SC_NEED_SELF_REKEY",
		Desc:   e.Error(),
		Fields: []keybase1.StringKVPair{kv},
	}
}
182894
func (c *cluster) unprotectedStatus() *ClusterStatus {
	return &ClusterStatus{
		ClusterID: c.id,
		State:     c.state,
		Nodes:     c.nodes,
	}
}
485942
func (e ServerErrorMissingFolderHandle) ToStatus() (s keybase1.Status) {
	s.Code = StatusCodeServerErrorMissingFolderHandle
	s.Name = "MISSING_FOLDER_HANDLE"
	s.Desc = e.Error()
	return
}
1208504
func (s *MigrationService) MigrationStatus(ctx context.Context, org string, id int64) (*Migration, *Response, error) {
	u := fmt.Sprintf("orgs/%v/migrations/%v", org, id)

	req, err := s.client.NewRequest("GET", u, nil)
	if err != nil {
		return nil, nil, err
	}

	// TODO: remove custom Accept header when this API fully launches.
	req.Header.Set("Accept", mediaTypeMigrationsPreview)

	m := &Migration{}
	resp, err := s.client.Do(ctx, req, m)
	if err != nil {
		return nil, resp, err
	}

	return m, resp, nil
}
1122111
func (e ServerErrorConflictPrevRoot) ToStatus() (s keybase1.Status) {
	s.Code = StatusCodeServerErrorConflictPrevRoot
	s.Name = "CONFLICT_PREV_ROOT"
	s.Desc = e.Error()
	return
}
739586
func NewUserStatus(httpResponse *http.Response) (*UserStatus, error) {
	statusResponse := &UserStatus{HTTPResponse: httpResponse}

	defer closeResponseBody(httpResponse)

	body, err := ioutil.ReadAll(httpResponse.Body)
	if err != nil {
		Logger.Println("Error reading from API:", err)
		return statusResponse, err
	}

	err = json.Unmarshal(body, statusResponse)
	if err != nil {
		Logger.Println("Error parsing JSON:", err)
		return statusResponse, err
	}

	statusResponse.ID = strconv.Itoa(statusResponse.StatusData.ID)
	return statusResponse, nil
}