@@ -1375,11 +1375,15 @@ withErrorReflection x = idrisCatch x (\ e -> handle e >>= ierror)
13751375
13761376 -- Normalize error handler terms to produce the new messages
13771377 ctxt <- getContext
1378− let results = map (normalise ctxt []) (map fst handlers)
1378+ let results = map (normalise ctxt []) (map fst handlers) :: [Term]
13791379
1380+ -- For each handler term output, either discard it if it is Nothing or reify it the Haskell equivalent
1381+ let errorpartsTT = mapMaybe unList (mapMaybe fromTTMaybe results) :: [[Term]]
1382+ errorparts <- mapM (mapM reifyReportPart) errorpartsTT
13801383
1381− errorparts <- mapM reifyReportPart (concat (mapMaybe unList (mapMaybe fromTTMaybe results)))
1382− return $ ReflectionError errorparts
1384+ return $ case errorparts of
1385+ [] -> e
1386+ parts -> ReflectionError errorparts e
13831387
13841388 fromTTMaybe :: Term -> Maybe Term -- WARNING: Assumes the term has type Maybe a
13851389 fromTTMaybe (App (App (P (DCon _ _) (NS (UN "Just") _) _) ty) tm) = Just tm