support mapping of os impl errors to Sigar*Exception classes

This commit is contained in:
Doug MacEachern 2006-01-04 22:45:31 +00:00
parent b9eb07e719
commit 1ec36664bc
1 changed files with 13 additions and 1 deletions

View File

@ -110,8 +110,20 @@ static void sigar_throw_notimpl(JNIEnv *env, char *msg)
static void sigar_throw_error(JNIEnv *env, jni_sigar_t *jsigar, int err) static void sigar_throw_error(JNIEnv *env, jni_sigar_t *jsigar, int err)
{ {
jclass errorClass; jclass errorClass;
int err_type = err;
switch (err) { /*
* support:
* #define SIGAR_EPERM_KMEM (SIGAR_OS_START_ERROR+EACCES)
* this allows for os impl specific message
* (e.g. Failed to open /dev/kmem) but still map to the proper
* Sigar*Exception
*/
if (err_type > SIGAR_OS_START_ERROR) {
err_type -= SIGAR_OS_START_ERROR;
}
switch (err_type) {
case SIGAR_ENOENT: case SIGAR_ENOENT:
errorClass = SIGAR_FIND_CLASS("SigarFileNotFoundException"); errorClass = SIGAR_FIND_CLASS("SigarFileNotFoundException");
break; break;