yellowtides / owenbot-hs

A utility bot written in Haskell for the Edinburgh Informatics Class of ‘24’s main messaging platform (Discord server).
https://yellowtid.es/owenbot-hs/
BSD 3-Clause "New" or "Revised" License
8 stars 7 forks source link

Handle IOException in DB module if file doesn't exist #42

Open yutotakano opened 3 years ago

yutotakano commented 3 years ago

The CSV module logs an error and returns an empty list if the target file doesn't for read. However, the DB module blindly calls BS.readFile and is prone to throwing an IOException if the file doesn't exist.

Real life case being if status.json doesn't exist on start up (which is sure to happen on the first time), the bot will fail to start at all. The status file should be either created empty, or ignored and operation continued.