From fa3966e00ea681212c439fc0f80c9f97a7f26b93 Mon Sep 17 00:00:00 2001 From: MO NAN <651932351@qq.com> Date: Mon, 11 Sep 2023 14:11:44 +0800 Subject: [PATCH] Add exception catch for swig (#3906) --- bcos-sdk/SWIG/BCOS.i | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bcos-sdk/SWIG/BCOS.i b/bcos-sdk/SWIG/BCOS.i index 0410694f70..5bb2881504 100644 --- a/bcos-sdk/SWIG/BCOS.i +++ b/bcos-sdk/SWIG/BCOS.i @@ -1,4 +1,15 @@ %module(directors="1") bcos + +%include exception.i +%exception { + try { + $action + } catch(std::exception &e) { + auto str = boost::diagnostic_information(e); + SWIG_exception(SWIG_RuntimeError, str.c_str()); + } +} + %include "Utilities.i" %include "Crypto.i" %include "Transaction.i"