mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-18 05:25:56 +08:00
chore: fix error handling
Signed-off-by: Shivanshu Raj Shrivastava <shivanshu1333@gmail.com>
This commit is contained in:
parent
f8341e8958
commit
14ce7f80e2
@ -3,7 +3,6 @@ package impltracefunnel
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/SigNoz/signoz/pkg/sqlstore"
|
||||
@ -43,10 +42,7 @@ func (store *store) Create(ctx context.Context, funnel *traceFunnels.Funnel) err
|
||||
Model(funnel).
|
||||
Exec(ctx)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "idx_trace_funnel_org_id_name") {
|
||||
return fmt.Errorf("a funnel with name '%s' already exists in this organization", funnel.Name)
|
||||
}
|
||||
return fmt.Errorf("failed to create funnel: %v", err)
|
||||
return store.sqlstore.WrapAlreadyExistsErrf(err, traceFunnels.ErrFunnelAlreadyExists, "a funnel with name '%s' already exists in this organization", funnel.Name)
|
||||
}
|
||||
|
||||
return nil
|
||||
@ -81,10 +77,7 @@ func (store *store) Update(ctx context.Context, funnel *traceFunnels.Funnel) err
|
||||
WherePK().
|
||||
Exec(ctx)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "idx_trace_funnel_org_id_name") {
|
||||
return fmt.Errorf("a funnel with name '%s' already exists in this organization", funnel.Name)
|
||||
}
|
||||
return fmt.Errorf("failed to update funnel: %v", err)
|
||||
return store.sqlstore.WrapAlreadyExistsErrf(err, traceFunnels.ErrFunnelAlreadyExists, "a funnel with name '%s' already exists in this organization", funnel.Name)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -1,12 +1,17 @@
|
||||
package tracefunnel
|
||||
|
||||
import (
|
||||
"github.com/SigNoz/signoz/pkg/errors"
|
||||
v3 "github.com/SigNoz/signoz/pkg/query-service/model/v3"
|
||||
"github.com/SigNoz/signoz/pkg/types"
|
||||
"github.com/SigNoz/signoz/pkg/valuer"
|
||||
"github.com/uptrace/bun"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrFunnelAlreadyExists = errors.MustNewCode("funnel_already_exists")
|
||||
)
|
||||
|
||||
// BaseMetadata metadata for funnels
|
||||
type BaseMetadata struct {
|
||||
types.Identifiable // funnel id
|
||||
|
Loading…
x
Reference in New Issue
Block a user