diff options
author | SangYoun Kwak <sy.kwak@samsung.com> | 2024-07-03 15:38:34 +0900 |
---|---|---|
committer | SangYoun Kwak <sy.kwak@samsung.com> | 2024-07-03 16:18:20 +0900 |
commit | 4ce407ab0519612e9b21ce9727d39a8b262121d0 (patch) | |
tree | 0af51cb6bfcc680f0383a7645c0873a235a4c728 | |
parent | a0b4be55a825884d078939cf8ae034bbf7059475 (diff) | |
download | sensor-rpi-accepted/tizen_unified.tar.gz sensor-rpi-accepted/tizen_unified.tar.bz2 sensor-rpi-accepted/tizen_unified.zip |
Add exception handler to the create functionstizen_9.0_m2_releaseaccepted/tizen/unified/dev/20240708.001632accepted/tizen/unified/20240704.075646accepted/tizen/9.0/unified/20241030.233202tizen_9.0tizenaccepted/tizen_unified_devaccepted/tizen_unifiedaccepted/tizen_9.0_unified
Each sensor creator may throw an exception if connection to the sensor
is failed. To handle this exception, Try-catch statement is added to the
sensor_create functions for each sensor.
Change-Id: I2acccb1b0dc2939031c0ed7278851504af72507e
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
-rw-r--r-- | src/accelerometer/hal-backend-sensor-accel.cpp | 9 | ||||
-rw-r--r-- | src/gyroscope/hal-backend-sensor-gyro.cpp | 9 | ||||
-rw-r--r-- | src/magnetometer/hal-backend-sensor-magnet.cpp | 9 |
3 files changed, 21 insertions, 6 deletions
diff --git a/src/accelerometer/hal-backend-sensor-accel.cpp b/src/accelerometer/hal-backend-sensor-accel.cpp index 9d66893..a694ae6 100644 --- a/src/accelerometer/hal-backend-sensor-accel.cpp +++ b/src/accelerometer/hal-backend-sensor-accel.cpp @@ -7,8 +7,13 @@ static sensor_device_t accel_dev = NULL; static int sensor_create(sensor_device_t **devices) { - if (!accel_dev) - accel_dev = new accel_device; + if (!accel_dev) { + try { + accel_dev = new accel_device; + } catch (int error_ret) { + return 0; + } + } *devices = &accel_dev; return 1; diff --git a/src/gyroscope/hal-backend-sensor-gyro.cpp b/src/gyroscope/hal-backend-sensor-gyro.cpp index fc37fe7..61aaa9d 100644 --- a/src/gyroscope/hal-backend-sensor-gyro.cpp +++ b/src/gyroscope/hal-backend-sensor-gyro.cpp @@ -7,8 +7,13 @@ static sensor_device_t gyro_dev = NULL; static int sensor_create(sensor_device_t **devices) { - if (!gyro_dev) - gyro_dev = new gyro_device; + if (!gyro_dev) { + try { + gyro_dev = new gyro_device; + } catch (int error_ret) { + return 0; + } + } *devices = &gyro_dev; return 1; diff --git a/src/magnetometer/hal-backend-sensor-magnet.cpp b/src/magnetometer/hal-backend-sensor-magnet.cpp index 853c709..a7372d1 100644 --- a/src/magnetometer/hal-backend-sensor-magnet.cpp +++ b/src/magnetometer/hal-backend-sensor-magnet.cpp @@ -7,8 +7,13 @@ static sensor_device_t magnet_dev = NULL; static int sensor_create(sensor_device_t **devices) { - if (!magnet_dev) - magnet_dev = new magnet_device; + if (!magnet_dev) { + try { + magnet_dev = new magnet_device; + } catch (int error_ret) { + return 0; + } + } *devices = &magnet_dev; return 1; |