Errors defines a format for describing human readable error messages, that can also quote some source, in order to identify the source of an error.
{ code : Basics.Int
, title : String
, body : String
, args : Dict String String
, sources : List SourcePos.SourceLines
}
Common Error definition, for reporting errors to users.
This contains all the information needed to build a nice human readable error
message. The body is written in mdgriffith/elm-markup
and looks like this:
There was an error in your code.
|> Source
label = Look, here it is:
pos = 0
Please fix it. This is not a helpful error message.
{ title : String
, body : String
}
Defines the content of an error message.
The body is written in mdgriffith/elm-markup
and looks like this:
There was an error in your code.
|> Source
label = Look, here it is:
pos = 0
Please fix it. This is not a helpful error message.
An ErrorMessage
will be combined with some lines of source code that it can
quote, in order to produce an Error
.
(pos -> SourcePos.SourceLines) -> err -> Error
Defines the signature of a function for building Errors. This keeps the positional information variable, but requires a function to turn source code positions into quotes lines of source code.
Typically implementation of this will use the lookupError
functions and an
error catalogue of error messages.
lookupError : Dict Basics.Int ErrorMessage -> Basics.Int -> Dict String String -> List SourcePos.SourceLines -> Error
Looks up an ErrorMessage in an error catalogue and fills in its quoted source code and parameters to produce an Error.
lookupErrorNoArgs : Dict Basics.Int ErrorMessage -> Basics.Int -> List SourcePos.SourceLines -> Error
Looks up an ErrorMessage in an error catalogue and fills in its quoted source code to produce an Error.
document : Renderer content -> Error -> Mark.Document (List content)
elm-markup Document describing the format of an error.
asConsoleString : Error -> String
Renders an Error as a String for printing to the console with ANSI colours.
htmlRenderer : Renderer (Html.Styled.Html msg)
Renders an Error as HTML.