mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-18 13:35:53 +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 (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/SigNoz/signoz/pkg/sqlstore"
|
"github.com/SigNoz/signoz/pkg/sqlstore"
|
||||||
@ -43,10 +42,7 @@ func (store *store) Create(ctx context.Context, funnel *traceFunnels.Funnel) err
|
|||||||
Model(funnel).
|
Model(funnel).
|
||||||
Exec(ctx)
|
Exec(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if strings.Contains(err.Error(), "idx_trace_funnel_org_id_name") {
|
return store.sqlstore.WrapAlreadyExistsErrf(err, traceFunnels.ErrFunnelAlreadyExists, "a funnel with name '%s' already exists in this organization", funnel.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 nil
|
return nil
|
||||||
@ -81,10 +77,7 @@ func (store *store) Update(ctx context.Context, funnel *traceFunnels.Funnel) err
|
|||||||
WherePK().
|
WherePK().
|
||||||
Exec(ctx)
|
Exec(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if strings.Contains(err.Error(), "idx_trace_funnel_org_id_name") {
|
return store.sqlstore.WrapAlreadyExistsErrf(err, traceFunnels.ErrFunnelAlreadyExists, "a funnel with name '%s' already exists in this organization", funnel.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 nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,17 @@
|
|||||||
package tracefunnel
|
package tracefunnel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/SigNoz/signoz/pkg/errors"
|
||||||
v3 "github.com/SigNoz/signoz/pkg/query-service/model/v3"
|
v3 "github.com/SigNoz/signoz/pkg/query-service/model/v3"
|
||||||
"github.com/SigNoz/signoz/pkg/types"
|
"github.com/SigNoz/signoz/pkg/types"
|
||||||
"github.com/SigNoz/signoz/pkg/valuer"
|
"github.com/SigNoz/signoz/pkg/valuer"
|
||||||
"github.com/uptrace/bun"
|
"github.com/uptrace/bun"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
ErrFunnelAlreadyExists = errors.MustNewCode("funnel_already_exists")
|
||||||
|
)
|
||||||
|
|
||||||
// BaseMetadata metadata for funnels
|
// BaseMetadata metadata for funnels
|
||||||
type BaseMetadata struct {
|
type BaseMetadata struct {
|
||||||
types.Identifiable // funnel id
|
types.Identifiable // funnel id
|
||||||
|
Loading…
x
Reference in New Issue
Block a user