"Fossies" - the Fresh Open Source Software Archive

Member "pp-2.14.3/src/ErrorMessages.hs" (24 Nov 2021, 4020 Bytes) of package /linux/privat/pp-2.14.3.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Haskell source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "ErrorMessages.hs": 2.14.2_vs_2.14.3.

    1 {- PP
    2 
    3 Copyright (C) 2015-2021 Christophe Delord
    4 
    5 http://cdelord.fr/pp
    6 
    7 This file is part of PP.
    8 
    9 PP is free software: you can redistribute it and/or modify
   10 it under the terms of the GNU General Public License as published by
   11 the Free Software Foundation, either version 3 of the License, or
   12 (at your option) any later version.
   13 
   14 PP is distributed in the hope that it will be useful,
   15 but WITHOUT ANY WARRANTY; without even the implied warranty of
   16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   17 GNU General Public License for more details.
   18 
   19 You should have received a copy of the GNU General Public License
   20 along with PP.  If not, see <http://www.gnu.org/licenses/>.
   21 -}
   22 
   23 {-# LANGUAGE CPP #-}
   24 
   25 module ErrorMessages ( unexpectedEndOfFile
   26                      , arityError
   27                      , invalidNameError
   28                      , builtinRedefinition
   29                      , fileNotFound
   30                      , codeblockError
   31                      , indentError
   32                      , macrocharsError
   33                      , macroargsError
   34                      , macroblockargsError
   35                      , literatemacrocharsError
   36                      , defaultParserConfigurationError
   37                      , exprError
   38                      , mustacheError
   39 #if linux_HOST_OS || darwin_HOST_OS
   40                      , windowsOnlyError
   41 #endif
   42                      )
   43 where
   44 
   45 import Data.Maybe
   46 
   47 import Environment
   48 
   49 -- raise an end of file error
   50 unexpectedEndOfFile :: Env -> FilePath -> t
   51 unexpectedEndOfFile env name = errorWithoutStackTrace $ "Unexpected end of file in " ++ fromMaybe "-" (currentFile env) ++
   52                                                         "\nAn argument of the macro \"" ++ name ++ "\" may not be correctly delimited."
   53 
   54 -- raise a file not found error
   55 fileNotFound :: FilePath -> t
   56 fileNotFound name = errorWithoutStackTrace $ "File not found: " ++ name
   57 
   58 -- raise an arity error
   59 arityError :: String -> t
   60 arityError name = errorWithoutStackTrace $ name ++ " wrong number of arguments"
   61 
   62 -- raise a wrong codeblock specification error
   63 codeblockError :: t
   64 codeblockError = errorWithoutStackTrace "codeblock expects a length higher than 3 and either a tilda or a backtick."
   65 
   66 -- raise a wrong indentation specification error
   67 indentError :: t
   68 indentError = errorWithoutStackTrace "indent expects a length higher than 3."
   69 
   70 -- raise an invalid name error
   71 invalidNameError :: String -> t
   72 invalidNameError name = errorWithoutStackTrace $ "\"" ++ name ++"\" is not a valid macro name."
   73 
   74 -- raise an builtin redefinition error
   75 builtinRedefinition :: String -> t
   76 builtinRedefinition name = errorWithoutStackTrace $ "\"" ++ name ++"\" is a built-in macro and can not be redefined."
   77 
   78 -- raise a parser consistency error
   79 macrocharsError :: String -> t
   80 macrocharsError chars = errorWithoutStackTrace $ "macrochars invalid parameter: \"" ++ chars ++ "\""
   81 
   82 -- raise a parser consistency error
   83 macroargsError :: String -> t
   84 macroargsError chars = errorWithoutStackTrace $ "macroargs invalid parameter: \"" ++ chars ++ "\""
   85 
   86 -- raise a parser consistency error
   87 macroblockargsError :: String -> t
   88 macroblockargsError chars = errorWithoutStackTrace $ "macroblockargs invalid parameter: \"" ++ chars ++ "\""
   89 
   90 -- raise a parser consistency error
   91 literatemacrocharsError :: String -> t
   92 literatemacrocharsError chars = errorWithoutStackTrace $ "literatemacrochars invalid parameter: \"" ++ chars ++ "\""
   93 
   94 -- raise a parser consistency error
   95 defaultParserConfigurationError :: t
   96 defaultParserConfigurationError = errorWithoutStackTrace "Unexpected error: Invalid parser configuration"
   97 
   98 #if linux_HOST_OS || darwin_HOST_OS
   99 windowsOnlyError :: String -> t
  100 windowsOnlyError name = errorWithoutStackTrace $ name ++ " is available on Windows only"
  101 #endif
  102 
  103 -- Expression parser error
  104 exprError :: String -> t
  105 exprError msg = errorWithoutStackTrace $ "Expression error: " ++ msg
  106 
  107 -- Mustache error
  108 mustacheError :: FilePath -> String -> t
  109 mustacheError file msg = errorWithoutStackTrace $ "Mustache ("++file++"): " ++ msg