exception: Add exceptions when context creation fails
* Exceptions only fired in constructor when it would initialise with a NULL context causing segfaults if used any further * Adds exception.i requirement to mraa.i for node.js and python support Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
11
src/mraa.i
11
src/mraa.i
@@ -1,5 +1,6 @@
|
||||
%include stdint.i
|
||||
%include std_string.i
|
||||
%include exception.i
|
||||
|
||||
#ifdef DOXYGEN
|
||||
%include common_hpp_doc.i
|
||||
@@ -26,6 +27,16 @@
|
||||
mraa_init();
|
||||
%}
|
||||
|
||||
%exception {
|
||||
try {
|
||||
$action
|
||||
} catch(const std::invalid_argument& e) {
|
||||
SWIG_exception(SWIG_ValueError, e.what());
|
||||
} catch(...) {
|
||||
SWIG_exception(SWIG_RuntimeError, "Unknown exception");
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(in) uint8_t = char;
|
||||
%typemap(in) unsigned char* = char*;
|
||||
%apply (char *STRING, size_t LENGTH) { (char *data, size_t length) };
|
||||
|
||||
Reference in New Issue
Block a user