{-# LANGUAGE ExistentialQuantification #-}

module Dormouse.Url.Exception
  ( UrlException(..)
  ) where

import Control.Exception.Safe (Exception(..))
import qualified Data.Text as T

-- | 'UrlException' is used to indicate an error in transforming a valid URI into a URL, e.g. the URI refers to a different schema such as @file@
newtype UrlException = UrlException  { UrlException -> Text
urlExceptionMessage :: T.Text }

instance Show UrlException where
  show :: UrlException -> String
show UrlException { urlExceptionMessage :: UrlException -> Text
urlExceptionMessage = Text
msg } = String
"Failed to parse url: " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Text -> String
T.unpack Text
msg

instance Exception UrlException