@@ -55,6 +55,7 @@ import qualified Text.Pandoc.Builder as B
5555import Text.Pandoc.Class (PandocMonad(..), report)
5656import Text.Pandoc.Definition
5757import Text.Pandoc.Emoji (emojis)
58+import Text.Pandoc.Error
5859import Text.Pandoc.Logging
5960import Text.Pandoc.Options
6061import Text.Pandoc.Parsing hiding (tableWith)
@@ -368,7 +369,9 @@ parseMarkdown = do
368369 -- lookup to get sourcepos
369370 case M.lookup n (stateNotes' st) of
370371 Just (pos, _) -> report (NoteDefinedButNotUsed n pos)
371− Nothing -> error "The impossible happened.") notesDefined
372+ Nothing -> throwError $
373+ PandocShouldNeverHappenError "note not found")
374+ notesDefined
372375 let doc = runF (do Pandoc _ bs <- B.doc <$> blocks
373376 meta <- stateMeta' st
374377 return $ Pandoc meta bs) st