mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44:37 +03:00
* Downgrade gqlgen to v0.17.2 The current version of gqlgen (v0.17.24) gives SIGILL crashes on armv7. * Update gqlparser
33 lines
648 B
Go
33 lines
648 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 gqlErr
|
|
}
|
|
return gqlerror.WrapPath(GetPath(ctx), err)
|
|
}
|