1 -- Reporting bugs in darcs.  See also impossible.h.
    2 module Darcs.Bug ( _bug, _bugDoc, _impossible, _fromJust
    3                  ) where
    4 
    5 import Printer ( Doc, errorDoc, text, ($$) )
    6 
    7 type BugStuff = (String, Int, String, String)
    8 
    9 _bug :: BugStuff -> String -> a
   10 _bug bs s = _bugDoc bs (text s)
   11 
   12 _bugDoc :: BugStuff -> Doc -> a
   13 _bugDoc bs s = errorDoc $
   14    text ("bug at " ++ _bugLoc bs) $$ s $$
   15    text ("See http://wiki.darcs.net/index.html/BugTrackerHowto " ++
   16          "for help on bug reporting.")
   17 
   18 _bugLoc :: BugStuff -> String
   19 _bugLoc (file, line, date, time) = file++":"++show line++" compiled "++time++" "++date
   20 
   21 _impossible :: BugStuff -> a
   22 _impossible bs = _bug bs $ "Impossible case at "++_bugLoc bs
   23 
   24 _fromJust :: BugStuff -> Maybe a -> a
   25 _fromJust bs mx =
   26   case mx of Nothing -> _bug bs $ "fromJust error at "++_bugLoc bs
   27              Just x  -> x