Skip to content

Commit

Permalink
Add throw exception
Browse files Browse the repository at this point in the history
  • Loading branch information
joonhaengHeo committed Nov 2, 2023
1 parent 674cbaf commit d960f4a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/controller/java/CHIPDeviceController-JNI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,14 +552,15 @@ JNI_METHOD(void, startOTAProvider)(JNIEnv * env, jobject self, jlong handle, job
CHIP_ERROR err = CHIP_NO_ERROR;
AndroidDeviceControllerWrapper * wrapper = AndroidDeviceControllerWrapper::FromJNIHandle(handle);

VerifyOrReturn(wrapper != nullptr, ChipLogError(Controller, "wrapper is null"));
VerifyOrExit(wrapper != nullptr, err = CHIP_ERROR_INCORRECT_STATE);

ChipLogProgress(Controller, "startOTAProvider() called");
err = wrapper->StartOTAProvider(otaProviderDelegate);

exit:
if (err != CHIP_NO_ERROR)
{
ChipLogError(Controller, "Failed to start OTA Provider.");
ChipLogError(Controller, "Failed to start OTA Provider. : %" CHIP_ERROR_FORMAT, err.Format());
JniReferences::GetInstance().ThrowError(env, sChipDeviceControllerExceptionCls, err);
}
#endif
Expand All @@ -572,15 +573,15 @@ JNI_METHOD(void, finishOTAProvider)(JNIEnv * env, jobject self, jlong handle)
CHIP_ERROR err = CHIP_NO_ERROR;
AndroidDeviceControllerWrapper * wrapper = AndroidDeviceControllerWrapper::FromJNIHandle(handle);

VerifyOrReturn(wrapper != nullptr, ChipLogError(Controller, "wrapper is null"));
VerifyOrExit(wrapper != nullptr, err = CHIP_ERROR_INCORRECT_STATE);

ChipLogProgress(Controller, "finishOTAProvider() called");

err = wrapper->FinishOTAProvider();

exit:
if (err != CHIP_NO_ERROR)
{
ChipLogError(Controller, "Failed to finish OTA Provider.");
ChipLogError(Controller, "Failed to finish OTA Provider. : %" CHIP_ERROR_FORMAT, err.Format());
JniReferences::GetInstance().ThrowError(env, sChipDeviceControllerExceptionCls, err);
}
#endif
Expand Down

0 comments on commit d960f4a

Please sign in to comment.