Skip to content

Instantly share code, notes, and snippets.

@dev-sawd
Last active February 5, 2022 16:40
chaincode panic recover
func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface) (pb pb.Response) {
defer func() (pb pb.Response) {
if err := recover(); err != nil {
fmt.Println("recover from invoke:", err)
debug.PrintStack()
// 또는 file로 에러 내용 저장
return shim.Error(fmt.Sprintf("invoke painc. err: %v", err))
}
}()
function, args := stub.GetFunctionAndParameters()
if function == "invoke" {
return t.invoke(stub, args)
}
// ...
return shim.Error("Invalid function")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment