diff --git a/en/application-dev/device/sensor-guidelines.md b/en/application-dev/device/sensor-guidelines.md index 6d8b040b11db1a0a225b1344b39526dc2493008a..734d75b2573d18ef261ea4f430ab907002fe1e3c 100644 --- a/en/application-dev/device/sensor-guidelines.md +++ b/en/application-dev/device/sensor-guidelines.md @@ -111,3 +111,15 @@ The following figure shows the successful call result when **SensorType** is **SENSOR_TYPE_ID_ACCELEROMETER**. ![en-us_image_0000001241733907](figures/en-us_image_0000001241733907.png) + + If the API fails to be called, you are advised to use the **try/catch** statement to capture error information that may occur in the code. Example: + + ``` + try { + sensor.once(sensor.sensorType.SENSOR_TYPE_ACCELEROMETER,function(data) { + console.info("Data obtained successfully. data=" + data);// The call is successful, and the obtained sensor data is printed. + }); + } catch (error) { + console.error(error); + } + ```