Skip to content

A peer-to-peer stack for code collaboration

Nicer error message and stack traces

Thomas Scholtes5a9554e984f7
diff --git a/src/Radicle/Internal/Annotation.hs b/src/Radicle/Internal/Annotation.hs
index 03ae057..394a078 100644
--- a/src/Radicle/Internal/Annotation.hs
+++ b/src/Radicle/Internal/Annotation.hs
@@ -4,8 +4,9 @@ module Radicle.Internal.Annotation where
import Codec.Serialise (Serialise)
import Data.Copointed (Copointed(..))
-import Data.Text (pack)
-import Protolude
+import qualified Data.Text as T
+import GHC.Stack
+import Protolude hiding (SrcLoc)
import qualified Text.Megaparsec.Pos as Par
import Radicle.Internal.Orphans ()
@@ -54,7 +55,10 @@ data SrcPos = SrcPos Par.SourcePos
instance Serialise SrcPos
thisPos :: HasCallStack => SrcPos
-thisPos = InternalPos (pack (prettyCallStack callStack))
+thisPos = InternalPos $ T.intercalate "\n" (map prettyCallSite $ getCallStack callStack)
+ where
+ prettyCallSite (f, SrcLoc{..}) =
+ toS $ srcLocFile <> show srcLocStartLine <> ":" <> show srcLocStartCol <> " " <> f
data WithPos a = WithPos SrcPos a
deriving (Read, Show, Generic, Functor, Foldable, Traversable)
@@ -73,4 +77,3 @@ instance Copointed WithPos where
instance Annotation WithPos where
toAnnotation = WithPos thisPos
-
diff --git a/src/Radicle/Internal/Pretty.hs b/src/Radicle/Internal/Pretty.hs
index c60d51c..22afa46 100644
--- a/src/Radicle/Internal/Pretty.hs
+++ b/src/Radicle/Internal/Pretty.hs
@@ -72,7 +72,7 @@ instance Pretty Ann.SrcPos where
instance PrettyV r => PrettyV (LangError r) where
prettyV (LangError stack err) = vsep $
- [prettyV err, "Call stack:"] ++ map pretty (reverse stack)
+ [prettyV err, indent 2 $ vsep $ map pretty (reverse stack)]
instance PrettyV r => PrettyV (LangErrorData r) where
prettyV v = case v of