github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/kbfs/idutil/errors.go (about)

     1  // Copyright 2019 Keybase Inc. All rights reserved.
     2  // Use of this source code is governed by a BSD
     3  // license that can be found in the LICENSE file.
     4  
     5  package idutil
     6  
     7  import (
     8  	"fmt"
     9  
    10  	kbname "github.com/keybase/client/go/kbun"
    11  	"github.com/keybase/client/go/protocol/keybase1"
    12  )
    13  
    14  // NoSigChainError means that a user we were trying to identify does
    15  // not have a sigchain.
    16  type NoSigChainError struct {
    17  	User kbname.NormalizedUsername
    18  }
    19  
    20  // Error implements the error interface for NoSigChainError.
    21  func (e NoSigChainError) Error() string {
    22  	return fmt.Sprintf("%s has not yet installed Keybase and set up the "+
    23  		"Keybase filesystem. Please ask them to.", e.User)
    24  }
    25  
    26  // NoCurrentSessionError indicates that the daemon has no current
    27  // session.  This is basically a wrapper for session.ErrNoSession,
    28  // needed to give the correct return error code to the OS.
    29  type NoCurrentSessionError struct {
    30  }
    31  
    32  // Error implements the error interface for NoCurrentSessionError.
    33  func (e NoCurrentSessionError) Error() string {
    34  	return "You are not logged into Keybase.  Try `keybase login`."
    35  }
    36  
    37  // NoSuchUserError indicates that the given user couldn't be resolved.
    38  type NoSuchUserError struct {
    39  	Input string
    40  }
    41  
    42  // Error implements the error interface for NoSuchUserError
    43  func (e NoSuchUserError) Error() string {
    44  	return fmt.Sprintf("%s is not a Keybase user", e.Input)
    45  }
    46  
    47  // ToStatus implements the keybase1.ToStatusAble interface for NoSuchUserError
    48  func (e NoSuchUserError) ToStatus() keybase1.Status {
    49  	return keybase1.Status{
    50  		Name: "NotFound",
    51  		Code: int(keybase1.StatusCode_SCNotFound),
    52  		Desc: e.Error(),
    53  	}
    54  }
    55  
    56  // NoSuchTeamError indicates that the given team couldn't be resolved.
    57  type NoSuchTeamError struct {
    58  	Input string
    59  }
    60  
    61  // Error implements the error interface for NoSuchTeamError
    62  func (e NoSuchTeamError) Error() string {
    63  	return fmt.Sprintf("%s is not a Keybase team", e.Input)
    64  }
    65  
    66  // TlfNameNotCanonical indicates that a name isn't a canonical, and
    67  // that another (not necessarily canonical) name should be tried.
    68  type TlfNameNotCanonical struct {
    69  	Name, NameToTry string
    70  }
    71  
    72  // Error implements the error interface for TlfNameNotCanonical.
    73  func (e TlfNameNotCanonical) Error() string {
    74  	return fmt.Sprintf("TLF name %s isn't canonical: try %s instead",
    75  		e.Name, e.NameToTry)
    76  }
    77  
    78  // NoSuchNameError indicates that the user tried to access a
    79  // subdirectory entry that doesn't exist.
    80  type NoSuchNameError struct {
    81  	Name      string
    82  	NameToLog string
    83  }
    84  
    85  // Error implements the error interface for NoSuchNameError
    86  func (e NoSuchNameError) Error() string {
    87  	n := e.Name
    88  	if len(e.NameToLog) > 0 {
    89  		n = e.NameToLog
    90  	}
    91  	return fmt.Sprintf("%s doesn't exist", n)
    92  }
    93  
    94  // BadTLFNameError indicates a top-level folder name that has an
    95  // incorrect format.
    96  type BadTLFNameError struct {
    97  	Name      string
    98  	NameToLog string
    99  }
   100  
   101  // Error implements the error interface for BadTLFNameError.
   102  func (e BadTLFNameError) Error() string {
   103  	n := e.Name
   104  	if len(e.NameToLog) > 0 {
   105  		n = e.NameToLog
   106  	}
   107  	return fmt.Sprintf("TLF name %s is in an incorrect format", n)
   108  }