本文整理匯總了Golang中github.com/youtube/vitess/go/vt/vterrors.WithSuffix函數的典型用法代碼示例。如果您正苦於以下問題:Golang WithSuffix函數的具體用法?Golang WithSuffix怎麽用?Golang WithSuffix使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了WithSuffix函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: formatError
func formatError(err error) error {
if err == nil {
return nil
}
s := fmt.Sprintf(", vtgate: %v", servenv.ListeningURL.String())
return vterrors.WithSuffix(err, s)
}
示例2: handleExecuteError
func handleExecuteError(err error, statsKey []string, query map[string]interface{}, logger *logutil.ThrottledLogger) {
s := fmt.Sprintf(", vtgate: %v", servenv.ListeningURL.String())
newErr := vterrors.WithSuffix(err, s)
errStr := newErr.Error()
if strings.Contains(errStr, errDupKey) {
infoErrors.Add("DupKey", 1)
} else if strings.Contains(errStr, errOutOfRange) {
infoErrors.Add("OutOfRange", 1)
} else if strings.Contains(errStr, errTxPoolFull) {
normalErrors.Add(statsKey, 1)
} else {
normalErrors.Add(statsKey, 1)
logError(err, query, logger)
}
}
示例3: handleExecuteError
func handleExecuteError(err error, statsKey []string, query map[string]interface{}, logger *logutil.ThrottledLogger) error {
// First we log in the right category.
ec := vterrors.RecoverVtErrorCode(err)
switch ec {
case vtrpcpb.ErrorCode_INTEGRITY_ERROR:
// Duplicate key error, no need to log.
infoErrors.Add("DupKey", 1)
case vtrpcpb.ErrorCode_RESOURCE_EXHAUSTED, vtrpcpb.ErrorCode_BAD_INPUT:
// Tx pool full error, or bad input, no need to log.
normalErrors.Add(statsKey, 1)
default:
// Regular error, we will log if caused by vtgate.
normalErrors.Add(statsKey, 1)
logError(err, query, logger)
}
// Then we suffix the error with our address.
s := fmt.Sprintf(", vtgate: %v", servenv.ListeningURL.String())
return vterrors.WithSuffix(err, s)
}