michalmonday / CSV-Parser-for-Arduino

It turns CSV string into an associative array (like dict in python)
MIT License
58 stars 12 forks source link

When SD card reader fails... #11

Closed hicksan closed 3 years ago

hicksan commented 3 years ago

I had a situation yesterday where my SD card reader library failed, due to an upgrade in the IDE overwriting changes I had made. The result was a quite spectacular runtime crash with "exception 28" invoked. That is not related to your library here.

However the crash happened because the cp data structure was empty when the system subsequently tried to read it. The data structures are all defined and populated inside the IF statement, so if the file read fails they are left undefined - which causes the crash. So I would like to add an "else" to the "if" confirming the file is open and readable. Inside that "else" I would like to populate the cp data structure with one row of empty data, and in one (any) character string insert the text "File read error" so it displays through my user interface without crashing it.

Please could you help with suggestions for such code, based on your example case? I have tried and failed so far.

hicksan commented 3 years ago

Fixed thank you.