module Wire.ParseException where

import Data.Text qualified as Text
import Imports

-- | Failed to parse a response from another service.
data ParseException = ParseException
  { ParseException -> Text
_parseExceptionRemote :: !Text,
    ParseException -> String
_parseExceptionMsg :: String
  }
  deriving stock (ParseException -> ParseException -> Bool
(ParseException -> ParseException -> Bool)
-> (ParseException -> ParseException -> Bool) -> Eq ParseException
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ParseException -> ParseException -> Bool
== :: ParseException -> ParseException -> Bool
$c/= :: ParseException -> ParseException -> Bool
/= :: ParseException -> ParseException -> Bool
Eq, Eq ParseException
Eq ParseException =>
(ParseException -> ParseException -> Ordering)
-> (ParseException -> ParseException -> Bool)
-> (ParseException -> ParseException -> Bool)
-> (ParseException -> ParseException -> Bool)
-> (ParseException -> ParseException -> Bool)
-> (ParseException -> ParseException -> ParseException)
-> (ParseException -> ParseException -> ParseException)
-> Ord ParseException
ParseException -> ParseException -> Bool
ParseException -> ParseException -> Ordering
ParseException -> ParseException -> ParseException
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: ParseException -> ParseException -> Ordering
compare :: ParseException -> ParseException -> Ordering
$c< :: ParseException -> ParseException -> Bool
< :: ParseException -> ParseException -> Bool
$c<= :: ParseException -> ParseException -> Bool
<= :: ParseException -> ParseException -> Bool
$c> :: ParseException -> ParseException -> Bool
> :: ParseException -> ParseException -> Bool
$c>= :: ParseException -> ParseException -> Bool
>= :: ParseException -> ParseException -> Bool
$cmax :: ParseException -> ParseException -> ParseException
max :: ParseException -> ParseException -> ParseException
$cmin :: ParseException -> ParseException -> ParseException
min :: ParseException -> ParseException -> ParseException
Ord, Int -> ParseException -> ShowS
[ParseException] -> ShowS
ParseException -> String
(Int -> ParseException -> ShowS)
-> (ParseException -> String)
-> ([ParseException] -> ShowS)
-> Show ParseException
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ParseException -> ShowS
showsPrec :: Int -> ParseException -> ShowS
$cshow :: ParseException -> String
show :: ParseException -> String
$cshowList :: [ParseException] -> ShowS
showList :: [ParseException] -> ShowS
Show)

instance Exception ParseException where
  displayException :: ParseException -> String
displayException (ParseException Text
r String
m) =
    String
"Failed to parse response from remote "
      String -> ShowS
forall a. [a] -> [a] -> [a]
++ Text -> String
Text.unpack Text
r
      String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" with message: "
      String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
m