Skip to content

Commit

Permalink
Add exception return in JNI (#25423)
Browse files Browse the repository at this point in the history
  • Loading branch information
joonhaengHeo authored and pull[bot] committed Dec 6, 2024
1 parent 39544a7 commit 1015349
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/controller/java/CHIPDeviceController-JNI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -734,12 +734,14 @@ JNI_METHOD(void, updateCommissioningNetworkCredentials)
{
ChipLogError(Controller, "ApplyNetworkCredentials failed. Err = %" CHIP_ERROR_FORMAT, err.Format());
JniReferences::GetInstance().ThrowError(env, sChipDeviceControllerExceptionCls, err);
return;
}
err = wrapper->UpdateCommissioningParameters(commissioningParams);
if (err != CHIP_NO_ERROR)
{
ChipLogError(Controller, "UpdateCommissioningParameters failed. Err = %" CHIP_ERROR_FORMAT, err.Format());
JniReferences::GetInstance().ThrowError(env, sChipDeviceControllerExceptionCls, err);
return;
}

// Only invoke NetworkCredentialsReady when called in response to NetworkScan result
Expand Down Expand Up @@ -919,6 +921,7 @@ JNI_METHOD(jstring, getIpAddress)(JNIEnv * env, jobject self, jlong handle, jlon
{
ChipLogError(Controller, "Failed to get device address.");
JniReferences::GetInstance().ThrowError(env, sChipDeviceControllerExceptionCls, err);
return nullptr;
}

addr.ToString(addrStr);
Expand Down Expand Up @@ -962,6 +965,7 @@ JNI_METHOD(jobject, getNetworkLocation)(JNIEnv * env, jobject self, jlong handle
{
ChipLogError(Controller, "Failed to get device address.");
JniReferences::GetInstance().ThrowError(env, sChipDeviceControllerExceptionCls, err);
return nullptr;
}

addr.GetIPAddress().ToString(addrStr);
Expand Down Expand Up @@ -1176,6 +1180,7 @@ JNI_METHOD(jbyteArray, getAttestationChallenge)
{
ChipLogProgress(Controller, "Could not cast device pointer to Device object");
JniReferences::GetInstance().ThrowError(env, sChipDeviceControllerExceptionCls, CHIP_ERROR_INCORRECT_STATE);
return nullptr;
}

err = chipDevice->GetAttestationChallenge(attestationChallenge);
Expand Down Expand Up @@ -1260,6 +1265,7 @@ JNI_METHOD(void, subscribe)
{
ChipLogError(Controller, "No device found");
JniReferences::GetInstance().ThrowError(env, sChipDeviceControllerExceptionCls, CHIP_ERROR_INCORRECT_STATE);
return;
}

std::vector<app::AttributePathParams> attributePathParamsList;
Expand Down Expand Up @@ -1311,6 +1317,7 @@ JNI_METHOD(void, read)
{
ChipLogError(Controller, "No device found");
JniReferences::GetInstance().ThrowError(env, sChipDeviceControllerExceptionCls, CHIP_ERROR_INCORRECT_STATE);
return;
}

std::vector<app::AttributePathParams> attributePathParamsList;
Expand Down

0 comments on commit 1015349

Please sign in to comment.