func NewInvocationError(err error) *InvocationError {
	if err == nil {
		return nil
	}
	frameInfo := getPanicInfo(err, 0)
	return &InvocationError{
		Message:    getErrorMessage(err),
		Name:       getErrorType(err),
		StackTrace: frameInfo.StackTrace,
		Stack:      formatStack(frameInfo.StackTrace),
	}
}
NewInvocationError returns an new InvocationError
package iopipe
import (
	"encoding/json"
	"fmt"
	"reflect"
	"runtime"
	"strings"
)
const defaultErrorFrameCount = 32
const framesToPanicInfo = 3  
func getErrorType(err interface{}) string {
	errorType := reflect.TypeOf(err)
	if errorType.Kind() == reflect.Ptr {
		return errorType.Elem().Name()
	}
	return errorType.Name()
}
type InvocationError struct {
	Message    string                  `json:"message"`
	Name       string                  `json:"name"`
	StackTrace []*panicErrorStackFrame `json:"-"`
	Stack      string                  `json:"stack"`
}
func (h *InvocationError) Error() string {
	errorJSON, _ := json.Marshal(h)
	return string(errorJSON)
}
func NewPanicInvocationError(err interface{}) *InvocationError {
	if err == nil {
		return nil
	}
	const framesToHide = framesToPanicInfo + 4  
	panicInfo := getPanicInfo(err, framesToHide)
	return &InvocationError{
		Message:    panicInfo.Message,
		Name:       getErrorType(err),
		StackTrace: panicInfo.StackTrace,
		Stack:      formatStack(panicInfo.StackTrace),
	}
}