From 6e4ae56ebdbc6c02e21586fd9360a3a049072d13 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Thu, 12 Jan 2012 11:04:41 +0000 Subject: Don't crash on UnmarshalError MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We hit UnmarshalError if the log contains messages using types like 'h' that dbus-core doesn't understand yet. We shouldn't crash when this happens. It would be better to show the warnings in the UI, so the user knows some messages are missing; or maybe even interleave them so we can show a warning inline to say “there should be a message here but we couldn't read it”. Another time. --- Bustle/Loader.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'Bustle/Loader.hs') diff --git a/Bustle/Loader.hs b/Bustle/Loader.hs index aefcd93..994aef8 100644 --- a/Bustle/Loader.hs +++ b/Bustle/Loader.hs @@ -5,6 +5,7 @@ module Bustle.Loader where import Control.Monad.Error +import Control.Arrow ((***)) import qualified Bustle.Loader.OldSkool as Old import qualified Bustle.Loader.Pcap as Pcap @@ -18,12 +19,12 @@ instance Error LoadError where readLog :: MonadIO io => FilePath - -> ErrorT LoadError io Log + -> ErrorT LoadError io ([String], Log) readLog f = do pcapResult <- io $ Pcap.readPcap f - liftM (filter (isRelevant . dmMessage)) $ case pcapResult of + liftM (id *** filter (isRelevant . dmMessage)) $ case pcapResult of Right ms -> return ms - Left _ -> readOldLogFile + Left _ -> liftM ((,) []) readOldLogFile where readOldLogFile = do input <- handleIOExceptions (LoadError f . show) $ readFile f -- cgit v1.2.3