Error check

Thread Starter

karunt

Joined Dec 4, 2025
1
Are there any industry best practices on error checking that one can refer to when writing code for espressif chips in ESP-IDF? I'm familiar with the use of esp_err_t and ESP_LOGs, but wondering if there's a certain approach that works well to make sure code recovers easily from failures and how many times to retry a certain piece of code before giving up altogether and publishing an error to a user interface. For instance, do people set up a separate error service and implement it across all their files, or do they locally implement different error checks in each of their code files (assuming a project has multiple files)? Any such guidance would be greatly appreciated since I haven't done much work on error checks and recovery.
 

Dave Lowther

Joined Sep 8, 2016
332
publishing an error to a user interface.
Just for that part of your question: I include a software error log. This records error messages including time stamp, file name, and line number. It's recorded to a file in the ESP32 flash (I use SPIFFS). Actually two files, when one is full it swaps to the other one after clearing it. The projects have a web UI. One of the options on the UI is view error log. I find this helpful for locating bugs.
 
Top