module Mpv.MpvError where

import Exon (exon)

import qualified Mpv.Data.MpvError as MpvError
import Mpv.Data.MpvError (MpvError (MpvError))
import Mpv.Data.Property (Property, propertyName)

amendError ::
  Text ->
  MpvError ->
  MpvError
amendError :: Text -> MpvError -> MpvError
amendError Text
info = \case
  MpvError Text
err ->
    Text -> MpvError
MpvError (Text -> Text
amend Text
err)
  MpvError.Fatal Text
err ->
    Text -> MpvError
MpvError.Fatal (Text -> Text
amend Text
err)
  where
    amend :: Text -> Text
amend Text
err =
      [exon|#{info}: #{err}|]

propError ::
  Property v ->
  MpvError ->
  MpvError
propError :: forall v. Property v -> MpvError -> MpvError
propError Property v
prop =
  Text -> MpvError -> MpvError
amendError [exon|getting #{show prop} ('#{propertyName prop}')|]

setPropError ::
  Property v ->
  MpvError ->
  MpvError
setPropError :: forall v. Property v -> MpvError -> MpvError
setPropError Property v
prop =
  Text -> MpvError -> MpvError
amendError [exon|setting #{show prop} ('#{propertyName prop}')|]

optionError ::
  Text ->
  Text ->
  MpvError ->
  MpvError
optionError :: Text -> Text -> MpvError -> MpvError
optionError Text
key Text
value =
  Text -> MpvError -> MpvError
amendError [exon|#{key} -> #{value}|]