diff options
author | Will Thompson <will@willthompson.co.uk> | 2012-01-12 11:04:41 +0000 |
---|---|---|
committer | Will Thompson <will@willthompson.co.uk> | 2012-01-12 11:04:41 +0000 |
commit | 6e4ae56ebdbc6c02e21586fd9360a3a049072d13 (patch) | |
tree | dbf4d74266f5540832f6954f4ff227ca7a178dd9 /Bustle/Loader.hs | |
parent | 94b6306a5b5f95c1a96a27543ac746e442726c87 (diff) |
Don't crash on UnmarshalError
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.
<https://bugs.freedesktop.org/show_bug.cgi?id=44714>
Diffstat (limited to 'Bustle/Loader.hs')
-rw-r--r-- | Bustle/Loader.hs | 7 |
1 files changed, 4 insertions, 3 deletions
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 |