Differentiate different exception types
This commit is contained in:
parent
82a2c1f463
commit
9cc73f29ff
1 changed files with 6 additions and 3 deletions
|
@ -18,7 +18,7 @@ import Prelude.Compat
|
||||||
import Control.DeepSeq
|
import Control.DeepSeq
|
||||||
(NFData (..))
|
(NFData (..))
|
||||||
import Control.Exception
|
import Control.Exception
|
||||||
(SomeException)
|
(SomeException (..))
|
||||||
import Control.Monad.Catch
|
import Control.Monad.Catch
|
||||||
(Exception)
|
(Exception)
|
||||||
import Data.Bifoldable
|
import Data.Bifoldable
|
||||||
|
@ -40,7 +40,7 @@ import Data.Text
|
||||||
import Data.Text.Encoding
|
import Data.Text.Encoding
|
||||||
(encodeUtf8)
|
(encodeUtf8)
|
||||||
import Data.Typeable
|
import Data.Typeable
|
||||||
(Typeable)
|
(Typeable, typeOf)
|
||||||
import GHC.Generics
|
import GHC.Generics
|
||||||
(Generic)
|
(Generic)
|
||||||
import Network.HTTP.Media
|
import Network.HTTP.Media
|
||||||
|
@ -76,7 +76,10 @@ instance Eq ServantError where
|
||||||
DecodeFailure t r == DecodeFailure t' r' = t == t' && r == r'
|
DecodeFailure t r == DecodeFailure t' r' = t == t' && r == r'
|
||||||
UnsupportedContentType mt r == UnsupportedContentType mt' r' = mt == mt' && r == r'
|
UnsupportedContentType mt r == UnsupportedContentType mt' r' = mt == mt' && r == r'
|
||||||
InvalidContentTypeHeader r == InvalidContentTypeHeader r' = r == r'
|
InvalidContentTypeHeader r == InvalidContentTypeHeader r' = r == r'
|
||||||
ConnectionError _ == ConnectionError _ = True
|
ConnectionError exc == ConnectionError exc' = eqSomeException exc exc'
|
||||||
|
where
|
||||||
|
-- returns true, if type of exception is the same
|
||||||
|
eqSomeException (SomeException a) (SomeException b) = typeOf a == typeOf b
|
||||||
|
|
||||||
-- prevent wild card blindness
|
-- prevent wild card blindness
|
||||||
FailureResponse {} == _ = False
|
FailureResponse {} == _ = False
|
||||||
|
|
Loading…
Reference in a new issue