aboutsummaryrefslogtreecommitdiffstats
path: root/src/Lib.hs
diff options
context:
space:
mode:
authorTeddy Wing2017-08-10 23:54:57 +0200
committerTeddy Wing2017-08-10 23:54:57 +0200
commitccf11b5467b2f41690390a20bc50a02c006be3f0 (patch)
tree376eff572bd78446f466c15672ab09df3e421e2e /src/Lib.hs
parent465f32c216bd9a9bd695f0a2f0f3a08369c51e9a (diff)
downloadsorbot-ccf11b5467b2f41690390a20bc50a02c006be3f0.tar.bz2
gitHubCommitAction: Get error handling to work using `Either`
Get rid of the `fail` and use an `Either` for error handling instead. This allows us to send back the response string like before, but provide an additional error message when no data comes back from the database query. Remove the old error handling code I had tried to set up previously.
Diffstat (limited to 'src/Lib.hs')
-rw-r--r--src/Lib.hs12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/Lib.hs b/src/Lib.hs
index 3b49136..f8745b2 100644
--- a/src/Lib.hs
+++ b/src/Lib.hs
@@ -2,11 +2,6 @@ module Lib
( someFunc
) where
-import Control.Exception (catch)
--- import System.Environment
--- import System.IO
--- import System.IO.Error
-
import Database.SQLite.Simple
import Message
@@ -22,8 +17,7 @@ someFunc = do
Just plugin = matchPlugin message
dbConn <- open "db/sorbot_development.sqlite3"
response <- performPlugin plugin message dbConn
- putStrLn response `catch` handleError
+ case response of
+ Left e -> putStrLn e
+ Right r -> putStrLn r
close dbConn
-
-handleError :: IOError -> IO ()
-handleError err = putStrLn $ show err