refactor error handling

This commit is contained in:
CismonX 2019-06-08 02:59:11 +08:00
parent 509e8a9ea2
commit 910125fccc
2 changed files with 9 additions and 4 deletions

View File

@ -32,14 +32,17 @@ namespace php_arma
if constexpr (!IsEq && std::is_same_v<T, cx_double>) {
zend_throw_exception(zend_ce_error, "no such comparation for complex elements", 0);
return false;
} else {
using dest_t = typename ChildT::with_int_elem_t;
using dest_native_t = typename dest_t::native_t;
auto ret = func(Z_NATIVE_OBJ_P(zv1), Z_NATIVE_OBJ_P(zv2)).eval();
RETVAL_OBJ(dest_t::create(std::move(arma::conv_to<dest_native_t>::from(ret))));
return true;
try {
auto ret = func(Z_NATIVE_OBJ_P(zv1), Z_NATIVE_OBJ_P(zv2)).eval();
RETVAL_OBJ(dest_t::create(std::move(arma::conv_to<dest_native_t>::from(ret))));
} catch (const std::logic_error& err) {
zend_throw_exception(zend_ce_error, err.what(), 0);
}
}
return true;
}
PHP_ARMA_COMMON_DECLARE();

View File

@ -22,6 +22,8 @@
#define ZEND_ACC_CTOR 0
#endif
#define ARMA_DONT_PRINT_ERRORS
/// Helper macros for method entry.
#define PHP_ARMA_START_ME(cls, ...) \