Skip to content
This repository has been archived by the owner on Jun 13, 2023. It is now read-only.

Commit

Permalink
fix stack hiding (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
enoodle authored Apr 10, 2020
1 parent 77cd6b1 commit 018666f
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions epsagon/lambda_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,15 @@ type preInvokeData struct {

type invocationData struct {
ExceptionInfo *protocol.Exception
errorStatus protocol.ErrorCode
result interface{}
err error
thrownError interface{}
errorStatus protocol.ErrorCode
result interface{}
err error
thrownError interface{}
}

type userError struct {
exception interface{}
stack string
}

func getAWSAccount(lc *lambdacontext.LambdaContext) string {
Expand Down Expand Up @@ -131,7 +136,7 @@ func (handler *epsagonLambdaWrapper) postInvokeOps(

// Invoke calls the handler, and creates a tracer for that duration.
func (handler *epsagonLambdaWrapper) Invoke(ctx context.Context, payload json.RawMessage) (result interface{}, err error) {
invokeInfo := &invocationData {}
invokeInfo := &invocationData{}
handler.invoked = false
handler.invoking = false
defer func() {
Expand All @@ -143,7 +148,10 @@ func (handler *epsagonLambdaWrapper) Invoke(ctx context.Context, payload json.Ra
result, err = handler.handler(ctx, payload)
}
if invokeInfo.thrownError != nil {
panic(invokeInfo.thrownError)
panic(userError{
exception: invokeInfo.thrownError,
stack: invokeInfo.ExceptionInfo.Traceback,
})
}
}()

Expand All @@ -163,8 +171,8 @@ func (handler *epsagonLambdaWrapper) InvokeClientLambda(
invokeInfo.thrownError = recover()
if invokeInfo.thrownError != nil {
invokeInfo.ExceptionInfo = &protocol.Exception{
Type: "Runtime Error",
Message: fmt.Sprintf("%v", invokeInfo.thrownError),
Type: "Runtime Error",
Message: fmt.Sprintf("%v", invokeInfo.thrownError),
Traceback: string(debug.Stack()),
Time: GetTimestamp(),
}
Expand Down

0 comments on commit 018666f

Please sign in to comment.