From 3a7859e2147e714471717d4dcb58d9a19c24cb88 Mon Sep 17 00:00:00 2001 From: Alexander Polakov Date: Mon, 4 Feb 2013 03:17:50 +0400 Subject: Handle XReadBitmapFile errors --- src/Bitmap.hs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/Bitmap.hs') diff --git a/src/Bitmap.hs b/src/Bitmap.hs index c512ff2..9df2f67 100644 --- a/src/Bitmap.hs +++ b/src/Bitmap.hs @@ -46,9 +46,14 @@ loadBitmap d w p = do exist <- doesFileExist p if exist then do - (bw, bh, bp, _, _) <- readBitmapFile d w p - addFinalizer bp (freePixmap d bp) - return $ Just $ Bitmap bw bh bp + bmap <- readBitmapFile d w p + case bmap of + Right (bw, bh, bp, _, _) -> do + addFinalizer bp (freePixmap d bp) + return $ Just $ Bitmap bw bh bp + Left err -> do + putStrLn err + return Nothing else return Nothing -- cgit v1.2.3