1 /* -*- Mode: C; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the Mozilla Public License Version 2.0.
7 // See license.mkd for licensing and copyright information.
8 // -------------------------------------------------------------------------*/
13 #include "squirreljme.h"
14 #include "sjme/debug.h"
16 sjme_jboolean
sjme_jni_checkVMException(JNIEnv
* env
)
18 /* Was there an exception? */
19 if ((*env
)->ExceptionCheck(env
))
22 (*env
)->ExceptionDescribe(env
);
28 return SJME_JNI_FALSE
;
31 void sjme_jni_throwMLECallError(JNIEnv
* env
, sjme_errorCode code
)
33 sjme_jni_throwThrowable(env
, code
,
34 "cc/squirreljme/jvm/mle/exceptions/MLECallError");
37 void sjme_jni_throwThrowable(JNIEnv
* env
, sjme_errorCode code
,
44 /* Get the class where the exception is. */
45 tossingClass
= (*env
)->FindClass(env
, type
);
46 if (tossingClass
== NULL
)
48 sjme_die("Could not find exception class?");
52 /* Generate a message accordingly. */
53 memset(buf
, 0, sizeof(buf
));
54 snprintf(buf
, BUF_SIZE
- 1, "Native error: %d",
55 (int)sjme_error_default(code
));
56 buf
[BUF_SIZE
- 1] = 0;
59 if ((*env
)->ThrowNew(env
, tossingClass
, buf
) != 0)
60 sjme_die("Could not throw a new throwable?");
64 void sjme_jni_throwVMException(JNIEnv
* env
, sjme_errorCode code
)
66 sjme_jni_throwThrowable(env
, code
,
67 "cc/squirreljme/emulator/vm/VMException");