github.com/machinefi/w3bstream@v1.6.5-rc9.0.20240426031326-b8c7c4876e72/pkg/depends/conf/jwt/error__generated.go (about)

     1  // This is a generated source file. DO NOT EDIT
     2  // Source: jwt/error__generated.go
     3  
     4  package jwt
     5  
     6  import "github.com/machinefi/w3bstream/pkg/depends/kit/statusx"
     7  
     8  var _ statusx.Error = (*Error)(nil)
     9  
    10  func (v Error) StatusErr() *statusx.StatusErr {
    11  	return &statusx.StatusErr{
    12  		Key:       v.Key(),
    13  		Code:      v.Code(),
    14  		Msg:       v.Msg(),
    15  		CanBeTalk: v.CanBeTalk(),
    16  	}
    17  }
    18  
    19  func (v Error) Unwrap() error {
    20  	return v.StatusErr()
    21  }
    22  
    23  func (v Error) Error() string {
    24  	return v.StatusErr().Error()
    25  }
    26  
    27  func (v Error) StatusCode() int {
    28  	return statusx.StatusCodeFromCode(int(v))
    29  }
    30  
    31  func (v Error) Code() int {
    32  	if with, ok := (interface{})(v).(statusx.ServiceCode); ok {
    33  		return with.ServiceCode() + int(v)
    34  	}
    35  	return int(v)
    36  }
    37  
    38  func (v Error) Key() string {
    39  	switch v {
    40  	case Unauthorized:
    41  		return "Unauthorized"
    42  	case InvalidToken:
    43  		return "InvalidToken"
    44  	case InvalidClaim:
    45  		return "InvalidClaim"
    46  	}
    47  	return "UNKNOWN"
    48  }
    49  
    50  func (v Error) Msg() string {
    51  	switch v {
    52  	case Unauthorized:
    53  		return ""
    54  	case InvalidToken:
    55  		return "Invalid Token"
    56  	case InvalidClaim:
    57  		return "Invalid Claim"
    58  	}
    59  	return "-"
    60  }
    61  
    62  func (v Error) CanBeTalk() bool {
    63  	switch v {
    64  	case Unauthorized:
    65  		return false
    66  	case InvalidToken:
    67  		return true
    68  	case InvalidClaim:
    69  		return true
    70  	}
    71  	return false
    72  }