[hal] Properly error check readCANStreamSession (#6108)

This commit is contained in:
Thad House
2023-12-29 21:57:00 -08:00
committed by GitHub
parent cc631d2a69
commit 636ef58d94
3 changed files with 19 additions and 1 deletions

View File

@@ -46,6 +46,7 @@ static JException canMessageNotFoundExCls;
static JException canMessageNotAllowedExCls;
static JException canNotInitializedExCls;
static JException uncleanStatusExCls;
static JException nullPointerEx;
static JClass powerDistributionVersionCls;
static JClass pwmConfigDataResultCls;
static JClass canStatusCls;
@@ -85,7 +86,8 @@ static const JExceptionInit exceptions[] = {
&canMessageNotAllowedExCls},
{"edu/wpi/first/hal/can/CANNotInitializedException",
&canNotInitializedExCls},
{"edu/wpi/first/hal/util/UncleanStatusException", &uncleanStatusExCls}};
{"edu/wpi/first/hal/util/UncleanStatusException", &uncleanStatusExCls},
{"java/lang/NullPointerException", &nullPointerEx}};
namespace hal {
@@ -212,6 +214,10 @@ void ReportCANError(JNIEnv* env, int32_t status, int message_id) {
}
}
void ThrowNullPointerException(JNIEnv* env, std::string_view msg) {
nullPointerEx.Throw(env, msg);
}
void ThrowCANStreamOverflowException(JNIEnv* env, jobjectArray messages,
jint length) {
static jmethodID constructor =