Skip to content

Commit

Permalink
Handle errors gracefully on routes (#93)
Browse files Browse the repository at this point in the history
* fix error handling on GetServingEnvs

Signed-off-by: Isabella Basso do Amaral <[email protected]>

* use semantic error const on BuildListOption

Signed-off-by: Isabella Basso do Amaral <[email protected]>

* use http status code enum

Signed-off-by: Isabella Basso do Amaral <[email protected]>

* simplify status code conversion on routes

Signed-off-by: Isabella Basso do Amaral <[email protected]>

---------

Signed-off-by: Isabella Basso do Amaral <[email protected]>
  • Loading branch information
isinyaaa authored May 16, 2024
1 parent efe499d commit a32b1c9
Show file tree
Hide file tree
Showing 3 changed files with 186 additions and 270 deletions.
5 changes: 3 additions & 2 deletions internal/apiutils/api_utils.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package apiutils

import (
"fmt"

"github.com/kubeflow/model-registry/internal/converter"
"github.com/kubeflow/model-registry/internal/ml_metadata/proto"
"github.com/kubeflow/model-registry/pkg/api"
model "github.com/kubeflow/model-registry/pkg/openapi"
)

func BuildListOperationOptions(listOptions api.ListOptions) (*proto.ListOperationOptions, error) {

result := proto.ListOperationOptions{}
if listOptions.PageSize != nil {
result.MaxResultSize = listOptions.PageSize
Expand Down Expand Up @@ -63,7 +64,7 @@ func BuildListOption(pageSize string, orderBy model.OrderByField, sortOrder mode
if pageSize != "" {
conv, err := converter.StringToInt32(pageSize)
if err != nil {
return api.ListOptions{}, err
return api.ListOptions{}, fmt.Errorf("%v: %w", err, api.ErrBadRequest)
}
pageSizeInt32 = &conv
}
Expand Down
Loading

0 comments on commit a32b1c9

Please sign in to comment.