diff --git a/src/controller/java/CHIPDeviceController-JNI.cpp b/src/controller/java/CHIPDeviceController-JNI.cpp index fd4b0303fdce4c..48e2192c1d5281 100644 --- a/src/controller/java/CHIPDeviceController-JNI.cpp +++ b/src/controller/java/CHIPDeviceController-JNI.cpp @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include @@ -1365,10 +1366,18 @@ JNI_METHOD(void, getConnectedDevicePointer)(JNIEnv * env, jobject self, jlong ha AndroidDeviceControllerWrapper * wrapper = AndroidDeviceControllerWrapper::FromJNIHandle(handle); GetConnectedDeviceCallback * connectedDeviceCallback = reinterpret_cast(callbackHandle); - VerifyOrReturn(connectedDeviceCallback != nullptr, ChipLogError(Controller, "GetConnectedDeviceCallback handle is nullptr")); + VerifyOrExit(connectedDeviceCallback != nullptr, err = CHIP_ERROR_INVALID_ARGUMENT); err = wrapper->Controller()->GetConnectedDevice(static_cast(nodeId), &connectedDeviceCallback->mOnSuccess, &connectedDeviceCallback->mOnFailure); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Controller, "Error invoking GetConnectedDevice")); +exit: + if (err != CHIP_NO_ERROR) + { + ChipLogError(Controller, "GetConnectedDevice failed: %" CHIP_ERROR_FORMAT, err.Format()); + OperationalSessionSetup::ConnnectionFailureInfo failureInfo( + chip::ScopedNodeId(static_cast(nodeId), wrapper->Controller()->GetFabricIndex()), err, + SessionEstablishmentStage::kUnknown); + connectedDeviceCallback->mOnFailure.mCall(&connectedDeviceCallback->mOnFailure.mContext, failureInfo); + } } JNI_METHOD(void, releaseOperationalDevicePointer)(JNIEnv * env, jobject self, jlong devicePtr)