+ //If error code is failure then RE Cache module should
+ //do clean up for caching flags, maps etc.
+ if(eCode > 4)
+ {
+ OIC_LOG_V(ERROR, TAG, "Error code: %d",eCode);
+ try
+ {
+ std::shared_ptr<RCSRemoteResourceObject> resource = resourcePtr.lock();
+ if(resource)
+ {
+ resource->stopCaching();
+ }
+ else
+ {
+ OIC_LOG(ERROR, TAG, "Resource object is null");
+ }
+ }
+ catch(...)
+ {
+ //Exception will be thrown: stack will return OC_STACK_ERROR
+ // if it already stopped observe. This call is reqired for clearing
+ //Cache manager.
+ OIC_LOG(DEBUG, TAG, "Cleared Cache");
+ }
+ }
+
+ //Calling application callback
+ onCacheUpdated(data, eCode);