#include "common/logger.h"
#include "common/typeutil.h"
#include "common/filesystem/filesystem_provider.h"
+#include "common/scope_exit.h"
namespace extension {
namespace download {
connection_h connection = nullptr;
connection_create(&connection);
+ SCOPE_EXIT {
+ connection_destroy(connection);
+ };
connection_cellular_state_e cell_state = CONNECTION_CELLULAR_STATE_OUT_OF_SERVICE;
connection_wifi_state_e wifi_state = CONNECTION_WIFI_STATE_DEACTIVATED;
connection_type_e connection_type = CONNECTION_TYPE_DISCONNECTED;
connection_get_type(connection, &connection_type);
- connection_destroy(connection);
+ if (CONNECTION_TYPE_DISCONNECTED == connection_type) {
+ LogAndReportError(
+ common::PlatformResult(common::ErrorCode::UNKNOWN_ERR, "Connection problem occured"),
+ &out, ("Connection type is disconnected"));
+ return;
+ }
bool network_available = false;
bool cell_available = (CONNECTION_CELLULAR_STATE_CONNECTED == cell_state);