chore: refactor error comparison (#3629)
This commit is contained in:
@@ -3,6 +3,7 @@ package sqlx
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
"errors"
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/trace"
|
"github.com/zeromicro/go-zero/core/trace"
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
@@ -23,7 +24,7 @@ func startSpan(ctx context.Context, method string) (context.Context, oteltrace.S
|
|||||||
func endSpan(span oteltrace.Span, err error) {
|
func endSpan(span oteltrace.Span, err error) {
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
if err == nil || err == sql.ErrNoRows {
|
if err == nil || errors.Is(err, sql.ErrNoRows) {
|
||||||
span.SetStatus(codes.Ok, "")
|
span.SetStatus(codes.Ok, "")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user