mirror of
https://github.com/stashapp/stash.git
synced 2025-12-06 08:26:00 +01:00
* Bump golang.org/x/text from 0.3.7 to 0.3.8 Bumps [golang.org/x/text](https://github.com/golang/text) from 0.3.7 to 0.3.8. - [Release notes](https://github.com/golang/text/releases) - [Commits](https://github.com/golang/text/compare/v0.3.7...v0.3.8) --- updated-dependencies: - dependency-name: golang.org/x/text dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> * Update go dependencies * Update x/net --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
33 lines
716 B
Go
33 lines
716 B
Go
package graphql
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
|
|
"github.com/vektah/gqlparser/v2/gqlerror"
|
|
)
|
|
|
|
type ErrorPresenterFunc func(ctx context.Context, err error) *gqlerror.Error
|
|
|
|
func DefaultErrorPresenter(ctx context.Context, err error) *gqlerror.Error {
|
|
var gqlErr *gqlerror.Error
|
|
if errors.As(err, &gqlErr) {
|
|
return gqlErr
|
|
}
|
|
return gqlerror.WrapPath(GetPath(ctx), err)
|
|
}
|
|
|
|
func ErrorOnPath(ctx context.Context, err error) error {
|
|
if err == nil {
|
|
return nil
|
|
}
|
|
var gqlErr *gqlerror.Error
|
|
if errors.As(err, &gqlErr) {
|
|
if gqlErr.Path == nil {
|
|
gqlErr.Path = GetPath(ctx)
|
|
}
|
|
// Return the original error to avoid losing any attached annotation
|
|
return err
|
|
}
|
|
return gqlerror.WrapPath(GetPath(ctx), err)
|
|
}
|