fixed exception handling in native code