mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-16 21:45:58 +08:00
chore: use errors package
Signed-off-by: Shivanshu Raj Shrivastava <shivanshu1333@gmail.com>
This commit is contained in:
parent
26ad89ed70
commit
37b26a7116
@ -2,7 +2,7 @@ package impltracefunnel
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"github.com/SigNoz/signoz/pkg/errors"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/SigNoz/signoz/pkg/sqlstore"
|
"github.com/SigNoz/signoz/pkg/sqlstore"
|
||||||
@ -24,11 +24,11 @@ func (store *store) Create(ctx context.Context, funnel *traceFunnels.StorableFun
|
|||||||
sqlstore.
|
sqlstore.
|
||||||
BunDB().
|
BunDB().
|
||||||
NewSelect().
|
NewSelect().
|
||||||
Model((*traceFunnels.StorableFunnel)(nil)).
|
Model(new(traceFunnels.StorableFunnel)).
|
||||||
Where("name = ? AND org_id = ?", funnel.Name, funnel.OrgID.String()).
|
Where("name = ? AND org_id = ?", funnel.Name, funnel.OrgID.String()).
|
||||||
Exists(ctx)
|
Exists(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to check for existing funnel: %v", err)
|
return errors.Wrapf(err, errors.TypeInternal, errors.CodeInternal, "failed to check for existing funnelr")
|
||||||
}
|
}
|
||||||
if exists {
|
if exists {
|
||||||
return store.sqlstore.WrapAlreadyExistsErrf(nil, traceFunnels.ErrFunnelAlreadyExists, "a funnel with name '%s' already exists in this organization", funnel.Name)
|
return store.sqlstore.WrapAlreadyExistsErrf(nil, traceFunnels.ErrFunnelAlreadyExists, "a funnel with name '%s' already exists in this organization", funnel.Name)
|
||||||
@ -41,7 +41,7 @@ func (store *store) Create(ctx context.Context, funnel *traceFunnels.StorableFun
|
|||||||
Model(funnel).
|
Model(funnel).
|
||||||
Exec(ctx)
|
Exec(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create funnel: %v", err)
|
return errors.Wrapf(err, errors.TypeInternal, errors.CodeInternal, "failed to create funnels")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -59,7 +59,7 @@ func (store *store) Get(ctx context.Context, uuid valuer.UUID, orgID valuer.UUID
|
|||||||
Where("?TableAlias.id = ? AND ?TableAlias.org_id = ?", uuid.String(), orgID.String()).
|
Where("?TableAlias.id = ? AND ?TableAlias.org_id = ?", uuid.String(), orgID.String()).
|
||||||
Scan(ctx)
|
Scan(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to get funnel: %v", err)
|
return nil, errors.Wrapf(err, errors.TypeInternal, errors.CodeInternal, "failed to get funnels")
|
||||||
}
|
}
|
||||||
return funnel, nil
|
return funnel, nil
|
||||||
}
|
}
|
||||||
@ -93,7 +93,7 @@ func (store *store) List(ctx context.Context, orgID valuer.UUID) ([]*traceFunnel
|
|||||||
Where("?TableAlias.org_id = ?", orgID.String()).
|
Where("?TableAlias.org_id = ?", orgID.String()).
|
||||||
Scan(ctx)
|
Scan(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to list funnels: %v", err)
|
return nil, errors.Wrapf(err, errors.TypeInternal, errors.CodeInternal, "failed to list funnels")
|
||||||
}
|
}
|
||||||
return funnels, nil
|
return funnels, nil
|
||||||
}
|
}
|
||||||
@ -104,11 +104,11 @@ func (store *store) Delete(ctx context.Context, funnelID valuer.UUID, orgID valu
|
|||||||
sqlstore.
|
sqlstore.
|
||||||
BunDB().
|
BunDB().
|
||||||
NewDelete().
|
NewDelete().
|
||||||
Model((*traceFunnels.StorableFunnel)(nil)).
|
Model(new(traceFunnels.StorableFunnel)).
|
||||||
Where("id = ? AND org_id = ?", funnelID.String(), orgID.String()).
|
Where("id = ? AND org_id = ?", funnelID.String(), orgID.String()).
|
||||||
Exec(ctx)
|
Exec(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to delete funnel: %v", err)
|
return errors.Wrapf(err, errors.TypeInternal, errors.CodeInternal, "failed to delete funnel")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user