-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathapiserver.go
32 lines (28 loc) · 1.12 KB
/
apiserver.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
Package apiserver contains all request handlers for gRPC and HTTP servers.
It has these top-level request handlers:
Admin - Administrative functionality related to managing the workflow engine.
Invocation - Functionality related to managing invocations.
Workflow - functionality related to managing workflows.
The purpose of this package is purely to provide handlers to gRPC and HTTP servers. Therefore,
it should not contain any logic (validation, composition, etc.) related to the workflows,
invocations or any other targets that it provides. All this logic should be placed in the actual
packages that are responsible for the business logic, such as `api`.
*/
package apiserver
import (
"github.com/fission/fission-workflows/pkg/types/validate"
"github.com/sirupsen/logrus"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
func toErrorStatus(err error) error {
switch err.(type) {
case validate.Error:
logrus.Errorf("Request error: %v", validate.FormatConcise(err))
return status.Error(codes.InvalidArgument, validate.Format(err))
default:
logrus.Errorf("Request error: %v", err)
return err
}
}