Skip to content

Commit

Permalink
PMM-11341 Status error instead common one.
Browse files Browse the repository at this point in the history
  • Loading branch information
JiriCtvrtka committed Nov 1, 2023
1 parent 6f99bb1 commit 67a9bf5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 1 addition & 2 deletions managed/services/inventory/agents.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"context"

"github.com/AlekSi/pointer"
"github.com/pkg/errors"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"gopkg.in/reform.v1"
Expand Down Expand Up @@ -502,7 +501,7 @@ func (as *AgentsService) ChangeQANMySQLSlowlogAgent(ctx context.Context, req *in
// AddPostgresExporter inserts postgres_exporter Agent with given parameters.
func (as *AgentsService) AddPostgresExporter(ctx context.Context, req *inventorypb.AddPostgresExporterRequest) (*inventorypb.PostgresExporter, error) {
if req.AutoDiscoveryLimit < 0 {
return nil, errors.New("auto discovery limit cannot be lower than 0")
return nil, status.Errorf(codes.InvalidArgument, "auto_discovery_limit cannot be lower than 0")
}

var res *inventorypb.PostgresExporter
Expand Down
5 changes: 3 additions & 2 deletions managed/services/management/postgresql.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import (
"context"

"github.com/AlekSi/pointer"
"github.com/pkg/errors"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"gopkg.in/reform.v1"

"github.com/percona/pmm/api/inventorypb"
Expand Down Expand Up @@ -49,7 +50,7 @@ func NewPostgreSQLService(db *reform.DB, state agentsStateUpdater, cc connection
// Add adds "PostgreSQL Service", "PostgreSQL Exporter Agent" and "QAN PostgreSQL PerfSchema Agent".
func (s *PostgreSQLService) Add(ctx context.Context, req *managementpb.AddPostgreSQLRequest) (*managementpb.AddPostgreSQLResponse, error) {
if req.AutoDiscoveryLimit < 0 {
return nil, errors.New("auto discovery limit cannot be lower than 0")
return nil, status.Errorf(codes.InvalidArgument, "auto_discovery_limit cannot be lower than 0")
}

res := &managementpb.AddPostgreSQLResponse{}
Expand Down

0 comments on commit 67a9bf5

Please sign in to comment.