{-# LANGUAGE CPP #-} -- | Module holding localized error messages to be presented as a response. -- -- To localize error messages provided by HURL, provide your translations between -- "BEGIN LOCALIZATION" & "END LOCALIZATION" in this file. -- -- The lines are formatted: -- trans ("LANG":_) (KEY) = "TRANSLATION" -- with uppercase indicating the bits you fill in. -- -- Translations between #if WITH_HTTP_URI & #endif are specific to HTTP error handling. module Network.URI.Messages (trans, Errors(..)) where import Data.List (stripPrefix) import Data.Maybe (fromMaybe) #if WITH_HTTP_URI import Network.HTTP.Client (HttpException(..), HttpExceptionContent(..)) import Control.Exception (displayException) import Network.TLS (TLSException(..), TLSError(..), AlertDescription(..)) import Control.Exception.Base (fromException) #endif trans _ (RawXML markup) = markup --- BEGIN LOCALIZATION trans ("en":_) (UnsupportedScheme scheme) = "Unsupported protocol " ++ scheme trans ("en":_) (UnsupportedMIME mime) = "Unsupported filetype " ++ mime trans ("en":_) (RequiresInstall mime appsMarkup) = "

Please install a compatible app to open " ++ linkType ++ " links

\n" ++ appsMarkup where linkType = fromMaybe mime $ stripPrefix "x-scheme-handler/" mime trans ("en":_) (OpenedWith app) = "Opened in " ++ app trans ("en":_) (ReadFailed msg) = "Failed to read file: " ++ msg trans ("en":_) MalformedResponse = "Invalid response!" trans ("en":_) ExcessiveRedirects = "Too many redirects!" #if WITH_HTTP_URI trans ("en":_) (Http (InvalidUrlException url msg)) = "Invalid URL " ++ url ++ ": " ++ msg trans ("en":_) (Http (HttpExceptionRequest _ (TooManyRedirects _))) = "Too many redirects!" trans ("en":_) (Http (HttpExceptionRequest _ ResponseTimeout)) = "The site took too long to respond!" trans ("en":_) (Http (HttpExceptionRequest _ ConnectionTimeout)) = "The site took too long to connect!" trans ("en":_) (Http (HttpExceptionRequest _ (ConnectionFailure err))) = "Could not connect: " ++ displayException err trans ("en":_) (Http (HttpExceptionRequest _ (InternalException e))) = case fromException e of Just (Terminated _ why _) -> "Secure session disconnected! " ++ why ++ "" Just (HandshakeFailed (Error_Misc msg)) -> "Failed to establish secure connection! " ++ msg ++ "" Just (HandshakeFailed (Error_Protocol (_, _, CloseNotify))) -> "Secure session disconnected!" Just (HandshakeFailed (Error_Protocol (_, _, HandshakeFailure))) -> "Failed to negotiate security parameters!" Just (HandshakeFailed (Error_Protocol (_, _, BadCertificate))) -> "

The site failed to prove it is who it says it is!

" Just (HandshakeFailed (Error_Protocol (_, _, UnsupportedCertificate))) -> unlines [ "

The site failed to prove it is who it says it is!

", "

It has sent us a cryptographic certificate I failed to make sense of.

" ] Just (HandshakeFailed (Error_Protocol (_, _, CertificateExpired))) -> unlines [ "

The site failed to prove it is who it says it is!

", "

The cryptographic certificate it has sent to us has expired!

" ] Just (HandshakeFailed (Error_Protocol (_, _, CertificateRevoked))) -> unlines [ "

The site failed to prove it is who it says it is!

", "

The cryptographic certificate it has sent us has been revoked!

" ] Just (HandshakeFailed (Error_Protocol (_, _, CertificateUnknown))) -> unlines [ "

The site failed to prove it is who it says it is!

", "

The cryptographic certificate it has sent us belongs to someone else!

" ] Just (HandshakeFailed (Error_Protocol (_, _, UnknownCa))) -> unlines [ "

The site failed to prove it is who it says it is!

", "

The authority vouching for it is unknown to me!

" ] Just (HandshakeFailed (Error_Protocol (why, _, _desc))) -> "Failed to establish secure connection! " ++ why ++ "" Just (HandshakeFailed (Error_Certificate why)) -> unlines [ "

The site failed to prove it is who it says it is!

", "

" ++ why ++ "

" ] Just (HandshakeFailed (Error_HandshakePolicy why)) -> "Invalid handshake policy: " ++ why ++ "" Just (HandshakeFailed Error_EOF) -> "Secure session disconnected!" Just (HandshakeFailed (Error_Packet why)) -> "Invalid security packet: " ++ why ++ "" Just (HandshakeFailed (Error_Packet_unexpected a b)) -> unlines [ "

Invalid security packet: " ++ a ++ "

", "

" ++ b ++ "

" ] Just (HandshakeFailed (Error_Packet_Parsing why)) -> "Invalid security packet: " ++ why ++ "" Just ConnectionNotEstablished -> "Attempted to send or recieve data before establishing secure connection!" Nothing -> "Internal error: " ++ displayException e #endif trans ("en":_) (GeminiError '1' '1' label) = "