robust FS_createDataFile error handling?

18 views
Skip to first unread message

juergen...@gmail.com

unread,
Jan 4, 2024, 2:12:53 PMJan 4
to emscripten-discuss
In one of my projects I am populating the FS via files that the user drag&drops on the page. I am using FS_createPath and then FS_createDataFile to create respective FS entries from the user supplied files.

Unfortunately it seems that older and more recent Emscripten versions behave differently in this context - which sucks.

Specifically I am performing the  FS_createDataFile in a try/catch to handle the scenario where a user repeatedly drops the same file, i.e. that file then already exists.

The older Emscripten version reacted to this scenario with err.message == 'File exists'
(it seems that the also supplied err.code unfortunartely was unusable garbage - which sucks). Though the check for a specific "message" - rather than some stable error code - seemed rather braindead, it at least allowed to properly handle the specific error scanario.

Unfornately it seems that the more recent Emscripten versions here have been made even worse: Now the err.message in this partucular scenario is "FS error" - which is a totally useless information and no longer allows to properly handle the specific error scenario.

I wonder what the "officially suggested" approach for this scanario might actually be - since the available exception handling obvisouly isn't fit for the task. (Since I don't want to support different implementations for use with different Emscripten versions, I am looking for a robost approach that actually works regardless of the used Emscripten version.)




Reply all
Reply to author
Forward
0 new messages