1
1
mirror of https://github.com/github/semantic.git synced 2025-01-02 12:23:08 +03:00

Pass the error up.

This commit is contained in:
Rob Rix 2019-09-30 17:20:35 -04:00
parent 9652ec9734
commit f1caf6beec
No known key found for this signature in database
GPG Key ID: F188A01508EA1CF7

View File

@ -6,7 +6,7 @@ module Control.Carrier.Parse.Simple
, ParseC(..)
, runParse
-- * Exceptions
, ParserCancelled(..)
, ParseFailure(..)
) where
import qualified Assigning.Assignment as Assignment
@ -50,11 +50,11 @@ runParser
runParser timeout blob@Blob{..} parser = case parser of
ASTParser language ->
parseToAST timeout language blob
>>= either (const (throwError (SomeException ParserTimedOut))) pure
>>= either (throwError . SomeException . ParseFailure) pure
UnmarshalParser language ->
parseToPreciseAST timeout language blob
>>= either (const (throwError (SomeException ParserTimedOut))) pure
>>= either (throwError . SomeException . ParseFailure) pure
AssignmentParser parser assignment ->
runParser timeout blob parser >>= either (throwError . toException) pure . Assignment.assign blobSource assignment
@ -66,7 +66,7 @@ runParser timeout blob@Blob{..} parser = case parser of
in length term `seq` pure term
SomeParser parser -> SomeTerm <$> runParser timeout blob parser
data ParserCancelled = ParserTimedOut
data ParseFailure = ParseFailure String
deriving (Show, Typeable)
instance Exception ParserCancelled
instance Exception ParseFailure