{-# LANGUAGE DeriveDataTypeable #-}
module Network.MPD.Core.Error where
import qualified Control.Exception as E
import Data.Typeable
data MPDError = NoMPD
| ConnectionError E.IOException
| Unexpected String
| Custom String
| ACK ACKType String
deriving (MPDError -> MPDError -> Bool
(MPDError -> MPDError -> Bool)
-> (MPDError -> MPDError -> Bool) -> Eq MPDError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MPDError -> MPDError -> Bool
$c/= :: MPDError -> MPDError -> Bool
== :: MPDError -> MPDError -> Bool
$c== :: MPDError -> MPDError -> Bool
Eq, Typeable)
instance E.Exception MPDError
instance Show MPDError where
show :: MPDError -> String
show MPDError
NoMPD = String
"Could not connect to MPD"
show (ConnectionError IOException
e) = String
"Connection error (" String -> ShowS
forall a. [a] -> [a] -> [a]
++ IOException -> String
forall a. Show a => a -> String
show IOException
e String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"
show (Unexpected String
s) = String
"MPD returned an unexpected response: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
unlines [
String
s
, String
""
, String
"This is most likely a bug in libmpd! Please report it here:"
, String
""
, String
"https://github.com/vimus/libmpd-haskell/issues/new"
]
show (Custom String
s) = String
s
show (ACK ACKType
_ String
s) = String
s
data ACKType = InvalidArgument
| InvalidPassword
| Auth
| UnknownCommand
| FileNotFound
| PlaylistMax
| System
| PlaylistLoad
| Busy
| NotPlaying
| FileExists
| UnknownACK
deriving ACKType -> ACKType -> Bool
(ACKType -> ACKType -> Bool)
-> (ACKType -> ACKType -> Bool) -> Eq ACKType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ACKType -> ACKType -> Bool
$c/= :: ACKType -> ACKType -> Bool
== :: ACKType -> ACKType -> Bool
$c== :: ACKType -> ACKType -> Bool
Eq