...

Source file src/edge-infra.dev/pkg/sds/emergencyaccess/types/errors.go

Documentation: edge-infra.dev/pkg/sds/emergencyaccess/types

     1  package types
     2  
     3  import (
     4  	"errors"
     5  	"strings"
     6  )
     7  
     8  var (
     9  	errNilProjectID  = errors.New("project id nil")
    10  	errNilBannerID   = errors.New("banner id nil")
    11  	errNilStoreID    = errors.New("store id nil")
    12  	errNilTerminalID = errors.New("terminal id nil")
    13  	errNilSessionID  = errors.New("session id nil")
    14  	errNilCommand    = errors.New("command nil")
    15  	errBothNil       = errors.New("both payload fields are empty")
    16  	errBothInit      = errors.New("both payload fields are initialized")
    17  )
    18  
    19  type userError struct {
    20  	err     error
    21  	userErr string
    22  }
    23  
    24  func (err userError) Error() string {
    25  	return err.err.Error()
    26  }
    27  
    28  func (err userError) userError() string {
    29  	return err.userErr
    30  }
    31  
    32  type ValidationErr []userError
    33  
    34  func (myerr ValidationErr) Error() string {
    35  	var msg []string
    36  	for _, err := range myerr {
    37  		msg = append(msg, err.Error())
    38  	}
    39  	return strings.Join(msg, ", ")
    40  }
    41  
    42  func (myerr ValidationErr) UserError() []string {
    43  	var msg []string
    44  	for _, err := range myerr {
    45  		msg = append(msg, err.userError())
    46  	}
    47  	return msg
    48  }
    49  

View as plain text