Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
CodeMap = make(map[string]Code)
)
Functions ¶
Types ¶
type Code ¶
type Code string
const ( CodSuccessCompletion Code = "00000" CodInternalError Code = "XX000" CodSqlclientUnableToEstablishSqlConnection Code = "08001" CodSqlserverRejectedEstablishmentOfSqlconnection Code = "08004" CodProtocolViolation Code = "08P01" CodDataException Code = "22000" CodInvalidParameterValue Code = "22023" CodUndefinedFunction Code = "42883" CodInvalidDatabaseName Code = "3F000" CodInvalidAuthorizationSpecification Code = "28000" CodSqlserverRejectedEstablishmentOfSqlSession Code = "08001" CodInvalidTransactionInitiation Code = "0B000" CodInFailedSqlTransaction Code = "25P02" )
type Error ¶
type Error interface { Error() string Message() string Cause() error Code() Code RetryDelay() int32 Stack() string }
On server side errors need to be returned using following interface.
An error can be created with:
errors.New errors.Wrap
if read == 0 && err == io.EOF { return errors.New(ErrReaderIsEmpty).WithCode(errors.CodInvalidParameterValue) }
or
u, err := s.getValidatedUser(r.user, r.Password)
if err != nil { return nil, errors.Wrap(err, "invalid user name or password").WithCode(errors.CodSqlserverRejectedEstablishmentOfSqlconnection) }
If the error is registered inside an init function like it's possible to skip the inline code definition.
func init() { ... errors.CodeMap[ErrMaxValueLenExceeded] = errors.CodDataException ... }
Errors are converted in the transportation in gRPC status. When adding a new error code it's required to add an entry in gRPC error map. See map.go
func mapGRPcErrorCode(code Code) codes.Code In order to avoid dependency between client and server package SDK contains proper error codes definitions, like server.
Both SDK ImmuError and server Error can be compared with errors.Is utility.
Click to show internal directories.
Click to hide internal directories.