Get to know MDN better
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
The error event is fired when an exception occurs on a sensor.
The Sensor interface is a base class, onerror and the error event may only be used on one of the derived classes.
After this event has occurred, the Sensor object becomes idle. If the sensor was reading values, it will stop until it restarts.
Use the event name in methods like addEventListener(), or set an event handler property.
A SensorErrorEvent. Inherits from Event.
Event SensorErrorEventIn addition to the properties listed below, properties from the parent interface, Event, are available.
error Read onlyReturns the DOMException that has been thrown.
This example adds an event listener to log errors occurred on an Accelerometer.
| Generic Sensor API # sensor-onerror |
Enable JavaScript to view this browser compatibility table.
This page was last modified on May 2, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.