mirror of
https://github.com/eclipse/upm.git
synced 2025-12-16 05:44:32 +03:00
wt5001: Added functions that throw exceptions when failing to read from sensors. Added java exception handling, and modified examples.
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com> Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
committed by
Mihai Tudor Panu
parent
7f7fdb8441
commit
fcb36276b7
21
src/java_exceptions.i
Normal file
21
src/java_exceptions.i
Normal file
@@ -0,0 +1,21 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
* java_exceptions.i
|
||||
*
|
||||
* SWIG library file providing java-specific exception handling in the upm library
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* Use this macro for functions that read data from a sensor and throw a
|
||||
* std::runtime_error in case of a read failure
|
||||
*/
|
||||
%define READDATA_EXCEPTION(function)
|
||||
%javaexception("java.io.IOException") function {
|
||||
try {
|
||||
$action
|
||||
} catch (std::runtime_error &e) {
|
||||
jclass clazz = jenv->FindClass("java/io/IOException");
|
||||
jenv->ThrowNew(clazz, e.what());
|
||||
return $null;
|
||||
}
|
||||
}
|
||||
%enddef
|
||||
Reference in New Issue
Block a user