@@ -26,25 +26,25 @@ type Request struct {
2626 Logger log.Logger
2727}
2828
29- func (r * Request ) handlePanic (ctx context.Context ) {
29+ func (r * Request ) handlePanic (ctx context.Context , queryString string ) {
3030 if value := recover (); value != nil {
3131 r .Logger .LogPanic (ctx , value )
32- r .AddError (makePanicError (value ))
32+ r .AddError (makePanicError (value , queryString ))
3333 }
3434}
3535
3636type extensionser interface {
3737 Extensions () map [string ]interface {}
3838}
3939
40- func makePanicError (value interface {}) * errors.QueryError {
41- return errors .Errorf ("graphql: panic occurred: %v" , value )
40+ func makePanicError (value interface {}, info string ) * errors.QueryError {
41+ return errors .Errorf ("graphql: panic occurred: %v\n %s \n \n " , value , info )
4242}
4343
44- func (r * Request ) Execute (ctx context.Context , s * resolvable.Schema , op * query.Operation ) ([]byte , []* errors.QueryError ) {
44+ func (r * Request ) Execute (ctx context.Context , s * resolvable.Schema , op * query.Operation , queryInfo string ) ([]byte , []* errors.QueryError ) {
4545 var out bytes.Buffer
4646 func () {
47- defer r .handlePanic (ctx )
47+ defer r .handlePanic (ctx , queryInfo )
4848 sels := selected .ApplyOperation (& r .Request , s , op )
4949 r .execSelections (ctx , sels , nil , s , s .Resolver , & out , op .Type == query .Mutation )
5050 }()
@@ -79,7 +79,7 @@ func (r *Request) execSelections(ctx context.Context, sels []selected.Selection,
7979 for _ , f := range fields {
8080 go func (f * fieldToExec ) {
8181 defer wg .Done ()
82- defer r .handlePanic (ctx )
82+ defer r .handlePanic (ctx , "" )
8383 f .out = new (bytes.Buffer )
8484 execFieldSelection (ctx , r , s , f , & pathSegment {path , f .field .Alias }, true )
8585 }(f )
@@ -178,7 +178,7 @@ func execFieldSelection(ctx context.Context, r *Request, s *resolvable.Schema, f
178178 defer func () {
179179 if panicValue := recover (); panicValue != nil {
180180 r .Logger .LogPanic (ctx , panicValue )
181- err = makePanicError (panicValue )
181+ err = makePanicError (panicValue , "" )
182182 err .Path = path .toSlice ()
183183 }
184184 }()
@@ -324,7 +324,7 @@ func (r *Request) execList(ctx context.Context, sels []selected.Selection, typ *
324324 for i := 0 ; i < l ; i ++ {
325325 go func (i int ) {
326326 defer wg .Done ()
327- defer r .handlePanic (ctx )
327+ defer r .handlePanic (ctx , "" )
328328 r .execSelectionSet (ctx , sels , typ .OfType , & pathSegment {path , i }, s , resolver .Index (i ), & entryouts [i ])
329329 }(i )
330330 }
0 commit comments