Array extension.

This commit is contained in:
Nuno Cruces
2023-11-21 13:40:55 +00:00
parent 22d1ae0068
commit 97d4248176
8 changed files with 257 additions and 55 deletions

View File

@@ -137,17 +137,25 @@ func (e ExtendedErrorCode) Timeout() bool {
return e == BUSY_TIMEOUT
}
func errorCode(err error, def ErrorCode) (code uint32) {
func errorCode(err error, def ErrorCode) (msg string, code uint32) {
switch code := err.(type) {
case ErrorCode:
return "", uint32(code)
case ExtendedErrorCode:
return "", uint32(code)
case nil:
return "", _OK
}
var ecode ErrorCode
var xcode xErrorCode
switch {
case errors.As(err, &xcode):
return uint32(xcode)
code = uint32(xcode)
case errors.As(err, &ecode):
return uint32(ecode)
code = uint32(ecode)
default:
code = uint32(def)
}
if err != nil {
return uint32(def)
}
return _OK
return err.Error(), code
}