{-# 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) import Control.Exception (Exception) trans _ (RawXML markup) = markup --- BEGIN LOCALIZATION ("en":_) `trans` UnsupportedScheme scheme = "Unsupported protocol " ++ scheme ("en":_) `trans` UnsupportedMIME mime = "Unsupported filetype " ++ mime ("en":_) `trans` RequiresInstall mime appsMarkup = "
" ++ linkType ++
"
linksContent-Length
header)"
("en":_) `trans` HTTPStatus 412 _ = "Webpage doesn't meet our preconditions."
("en":_) `trans` HTTPStatus 413 _ = "Payload too large, please upload a smaller file!"
("en":_) `trans` HTTPStatus 414 _ = "Web address is too long for the site!"
("en":_) `trans` HTTPStatus 415 _ = "No representation available for supported filetypes!"
("en":_) `trans` HTTPStatus 416 _ = "Invalid byte-range of requested resource!"
("en":_) `trans` HTTPStatus 417 _ = "Site cannot satisfy our stated expectations!"
("en":_) `trans` HTTPStatus 418 _ = unlines [
"I'm a little teapot
",
"Short and stout
",
"Here is my handle
",
"And here is my spout.
When I get all steamed up
",
"Hear me shout
",
"Tip me over
",
"And pour me out!
" ++ error ++ "
"
("en":_) `trans` InvalidUrl url message =
"Invalid web address " ++ url ++ "
: " ++ message ++ ""
("en":_) `trans` ProxyError msg code code' msg' = unlines [
"" ++ show code ++ " " ++ msg ++ "
", "" ++ show code' ++ " " ++ msg' ++ "
" ] ("en":_) `trans` InvalidRequest why = "Attempted to send invalid auxiliary data: " ++ why ++ "" ("en":_) `trans` InsecureUnestablished = "Attempted to send or recieve data before establishing secure connection!" ("en":_) `trans` InsecureCertificate why = unlines [ "" ++ why ++ "
", "Leave Insecure Site | ", "Accept Imposter Risk & Continue
" ] ("en":_) `trans` InsecureTerminated why = "Secure session disconnected! " ++ why ++ "" trans ("en":_) InsecureCertificateUnknownCA = "The authority vouching for it is unknown to me!" trans ("en":_) InsecureCertificateUnknown = "The cryptographic certificate it has sent us to prove its identity instead " ++ "belongs to someone else!" trans ("en":_) InsecureCertificateRevoked = "The cryptographic certificate it has sent us to prove its identity has been revoked!" trans ("en":_) InsecureCertificateExpired = "The cryptographic certificate it has sent us to prove its identity has expired!" trans ("en":_) InsecureCertificateUnsupported = "It has sent us a cryptographic certificate to prove its identity I failed to make sense of." ("en":_) `trans` HandshakePacketUnparsed why = "Invalid security packet: " ++ why ++ "" ("en":_) `trans` HandshakePacketUnexpected a b = unlines [ "Invalid security packet: " ++ a ++ "
", "" ++ b ++ "
" ] ("en":_) `trans` HandshakePacketInvalid why = "Invalid security packet: " ++ why ++ "" trans ("en":_) HandshakeEOF = "Secure session disconnected!" ("en":_) `trans` HandshakePolicy why = "Invalid handshake policy: " ++ why ++ "" ("en":_) `trans` HandshakeMisc why = "Failed to establish secure connection! " ++ why ++ "" trans ("en":_) HandshakeError = "Failed to negotiate security parameters!" trans ("en":_) HandshakeClosed = "Secure session disconnected!" ("en":_) `trans` FailedConnect why = "Failed to open connection to the site: " ++ why ++ "" trans ("en":_) TimeoutConnection = "The site took too long to connect!" trans ("en":_) TimeoutResponse = "The site took too long to respond!" --- END LOCALIZATION trans (_:locales) err = trans locales err trans [] err = show err data Errors = UnsupportedScheme String | UnsupportedMIME String | RequiresInstall String String | OpenedWith String | ReadFailed String | RawXML String | MalformedResponse String | ExcessiveRedirects | HTTPStatus Int String | GeminiError Char Char String | OtherException String | InvalidUrl String String | ProxyError String Int Int String | InvalidRequest String | InsecureUnestablished | InsecureCertificate String | InsecureTerminated String | InsecureCertificateUnknownCA | InsecureCertificateUnknown | InsecureCertificateRevoked | InsecureCertificateExpired | InsecureCertificateUnsupported | HandshakePacketUnparsed String | HandshakePacketUnexpected String String | HandshakePacketInvalid String | HandshakeEOF | HandshakePolicy String | HandshakeMisc String | HandshakeError | HandshakeClosed | FailedConnect String | TimeoutConnection | TimeoutResponse deriving (Show) instance Exception Errors