diff --git a/docs/content/en/docs/config/grpc/services/appprovider/_index.md b/docs/content/en/docs/config/grpc/services/appprovider/_index.md index 837b515d693..d06d011b766 100644 --- a/docs/content/en/docs/config/grpc/services/appprovider/_index.md +++ b/docs/content/en/docs/config/grpc/services/appprovider/_index.md @@ -9,7 +9,7 @@ description: > # _struct: config_ {{% dir name="mime_types" type="[]string" default=nil %}} -A list of mime types supported by this app. [[Ref]](https://github.com/cs3org/reva/tree/master/internal/grpc/services/appprovider/appprovider.go#L69) +A list of mime types supported by this app. [[Ref]](https://github.com/cs3org/reva/tree/master/internal/grpc/services/appprovider/appprovider.go#L68) {{< highlight toml >}} [grpc.services.appprovider] mime_types = nil @@ -17,7 +17,7 @@ mime_types = nil {{% /dir %}} {{% dir name="custom_mime_types_json" type="string" default="nil" %}} -An optional mapping file with the list of supported custom file extensions and corresponding mime types. [[Ref]](https://github.com/cs3org/reva/tree/master/internal/grpc/services/appprovider/appprovider.go#L70) +An optional mapping file with the list of supported custom file extensions and corresponding mime types. [[Ref]](https://github.com/cs3org/reva/tree/master/internal/grpc/services/appprovider/appprovider.go#L69) {{< highlight toml >}} [grpc.services.appprovider] custom_mime_types_json = "nil" diff --git a/docs/content/en/docs/config/http/services/archiver/_index.md b/docs/content/en/docs/config/http/services/archiver/_index.md index 5816ea09f13..56a4f4f622c 100644 --- a/docs/content/en/docs/config/http/services/archiver/_index.md +++ b/docs/content/en/docs/config/http/services/archiver/_index.md @@ -9,7 +9,7 @@ description: > # _struct: Config_ {{% dir name="insecure" type="bool" default=false %}} -Whether to skip certificate checks when sending requests. [[Ref]](https://github.com/cs3org/reva/tree/master/internal/http/services/archiver/handler.go#L62) +Whether to skip certificate checks when sending requests. [[Ref]](https://github.com/cs3org/reva/tree/master/internal/http/services/archiver/handler.go#L63) {{< highlight toml >}} [http.services.archiver] insecure = false diff --git a/internal/grpc/services/appprovider/appprovider.go b/internal/grpc/services/appprovider/appprovider.go index 7028c4f4d23..42283be1eff 100644 --- a/internal/grpc/services/appprovider/appprovider.go +++ b/internal/grpc/services/appprovider/appprovider.go @@ -21,7 +21,6 @@ package appprovider import ( "context" "encoding/json" - "errors" "fmt" "os" "strconv" @@ -211,7 +210,7 @@ func (s *service) OpenInApp(ctx context.Context, req *providerpb.OpenInAppReques appURL, err := s.provider.GetAppURL(ctx, req.ResourceInfo, req.ViewMode, req.AccessToken, req.Opaque.Map, s.conf.Language) if err != nil { res := &providerpb.OpenInAppResponse{ - Status: status.NewInternal(ctx, errors.New("appprovider: error calling GetAppURL"), err.Error()), + Status: status.NewStatusFromErrType(ctx, "appprovider: error calling GetAppURL", err), } return res, nil } diff --git a/internal/http/services/appprovider/appprovider.go b/internal/http/services/appprovider/appprovider.go index d6730e80450..e95a2e99a73 100644 --- a/internal/http/services/appprovider/appprovider.go +++ b/internal/http/services/appprovider/appprovider.go @@ -408,6 +408,10 @@ func (s *svc) handleOpen(w http.ResponseWriter, r *http.Request) { writeError(w, r, appErrorNotFound, openRes.Status.Message, nil) return } + if openRes.Status.Code == rpc.Code_CODE_ALREADY_EXISTS { + writeError(w, r, appErrorAlreadyExists, openRes.Status.Message, nil) + return + } writeError(w, r, appErrorServerError, openRes.Status.Message, status.NewErrorFromCode(openRes.Status.Code, "error calling OpenInApp")) return diff --git a/pkg/errtypes/errtypes.go b/pkg/errtypes/errtypes.go index 9af7d2b5350..bf54dd00c08 100644 --- a/pkg/errtypes/errtypes.go +++ b/pkg/errtypes/errtypes.go @@ -22,7 +22,7 @@ // and error is a reserved word :) package errtypes -// NotFound is the error to use when a something is not found. +// NotFound is the error to use when something is not found. type NotFound string func (e NotFound) Error() string { return "error: not found: " + string(e) } @@ -46,7 +46,7 @@ func (e PermissionDenied) Error() string { return "error: permission denied: " + // IsPermissionDenied implements the IsPermissionDenied interface. func (e PermissionDenied) IsPermissionDenied() {} -// AlreadyExists is the error to use when a resource something is not found. +// AlreadyExists is the error to use when a resource already exists and can't be overwritten. type AlreadyExists string func (e AlreadyExists) Error() string { return "error: already exists: " + string(e) } @@ -54,7 +54,7 @@ func (e AlreadyExists) Error() string { return "error: already exists: " + strin // IsAlreadyExists implements the IsAlreadyExists interface. func (e AlreadyExists) IsAlreadyExists() {} -// UserRequired represents an error when a resource is not found. +// UserRequired represents an error when a user could not be found from the context. type UserRequired string func (e UserRequired) Error() string { return "error: user required: " + string(e) } diff --git a/pkg/rgrpc/status/status.go b/pkg/rgrpc/status/status.go index 80197e05529..27c285bcbce 100644 --- a/pkg/rgrpc/status/status.go +++ b/pkg/rgrpc/status/status.go @@ -181,6 +181,8 @@ func NewStatusFromErrType(ctx context.Context, msg string, err error) *rpc.Statu return NewUnimplemented(ctx, err, "gateway: "+msg+":"+err.Error()) case errtypes.BadRequest: return NewInvalidArg(ctx, "gateway: "+msg+":"+err.Error()) + case errtypes.AlreadyExists: + return NewAlreadyExists(ctx, err, "gateway: "+msg+":"+err.Error()) } // map GRPC status codes coming from the auth middleware