service/dap: log stacktrace when panic is recovered (#2457)

This commit is contained in:
polinasok 2021-04-29 02:15:32 -07:00 committed by GitHub
parent 35d4f05c4e
commit ef337d3022
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -21,6 +21,7 @@ import (
"reflect"
"regexp"
"runtime"
"runtime/debug"
"strings"
"sync"
@ -318,6 +319,7 @@ func (s *Server) handleRequest(request dap.Message) {
// In case a handler panics, we catch the panic and send an error response
// back to the client.
if ierr := recover(); ierr != nil {
s.log.Errorf("stacktrace from recovered panic:\n%s\n", debug.Stack())
s.sendInternalErrorResponse(request.GetSeq(), fmt.Sprintf("%v", ierr))
}
}()