aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Error.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text/Pandoc/Error.hs')
-rw-r--r--src/Text/Pandoc/Error.hs13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Error.hs b/src/Text/Pandoc/Error.hs
index 135cb3945..3cf381168 100644
--- a/src/Text/Pandoc/Error.hs
+++ b/src/Text/Pandoc/Error.hs
@@ -1,7 +1,7 @@
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-
-Copyright (C) 2006-2016 John MacFarlane <jgm@berkeley.edu>
+Copyright (C) 2006-2017 John MacFarlane <jgm@berkeley.edu>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-}
{- |
Module : Text.Pandoc.Error
- Copyright : Copyright (C) 2006-2016 John MacFarlane
+ Copyright : Copyright (C) 2006-2017 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
@@ -42,10 +42,12 @@ import Text.Parsec.Pos hiding (Line)
import qualified Text.Pandoc.UTF8 as UTF8
import System.Exit (exitWith, ExitCode(..))
import System.IO (stderr)
+import Network.HTTP.Client (HttpException)
type Input = String
data PandocError = PandocIOError String IOError
+ | PandocHttpError String HttpException
| PandocShouldNeverHappenError String
| PandocSomeError String
| PandocParseError String
@@ -58,6 +60,7 @@ data PandocError = PandocIOError String IOError
| PandocPDFError String
| PandocFilterError String String
| PandocCouldNotFindDataFileError String
+ | PandocResourceNotFound String
| PandocAppError String
deriving (Show, Typeable, Generic)
@@ -69,6 +72,8 @@ handleError (Right r) = return r
handleError (Left e) =
case e of
PandocIOError _ err' -> ioError err'
+ PandocHttpError u err' -> err 61 $
+ "Could not fetch " ++ u ++ "\n" ++ show err'
PandocShouldNeverHappenError s -> err 62 s
PandocSomeError s -> err 63 s
PandocParseError s -> err 64 s
@@ -78,7 +83,7 @@ handleError (Left e) =
errColumn = sourceColumn errPos
ls = lines input ++ [""]
errorInFile = if length ls > errLine - 1
- then concat ["\n", (ls !! (errLine - 1))
+ then concat ["\n", ls !! (errLine - 1)
,"\n", replicate (errColumn - 1) ' '
,"^"]
else ""
@@ -94,6 +99,8 @@ handleError (Left e) =
filtername ++ ":\n" ++ msg
PandocCouldNotFindDataFileError fn -> err 97 $
"Could not find data file " ++ fn
+ PandocResourceNotFound fn -> err 99 $
+ "File " ++ fn ++ " not found in resource path"
PandocAppError s -> err 1 s
err :: Int -> String -> IO a