1 stable release
1.3.4 | Oct 19, 2024 |
---|
#583 in HTTP server
180 downloads per month
38KB
686 lines
Litho Diagnostics
This crate implements all diagnostics that Litho (a GraphQL framework) can emit.
Within Litho, these diagnostics are emitted by the lexer, parser, type checker and compiler. Typically, each of those can emit multiple diagnostics without bailing out after the first diagnostic, but the compiler will only advance to the next phase if there are no errors in the previous phase.
Usage
All diagnostics are generated by a DSL Macro (see source code), implement
DiagnosticInfo<S>
and are generic with respect to the span that triggered
the diagnostic. Diagnostics consist of an error code, name, message and zero or
more labels. Labels are additional hints that refer to a separate span in the
source code.
Example
Below is an example of a diagnostic that Litho generates:
MissingArgumentsClosingParentheses
. It starts with the code
in square
brackets, followed by a message
. It shows a snippet of the lines that caused
the diagnostic along with the primary span that starts at graphql:6:20
. And
finally, it also shows two more spans (first
and second
) with additional
hints.
[E0006] Error: Arguments are missing closing parenthesis.
╭─[graphql:6:20]
│
6 │ field(arg: true
· ┬ ┬
· ╰──────────── This `(` here ...
· │
· ╰── ... should have a matching `)` here.
───╯
License
Copyright 2022-2024 Glacyr B.V.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Dependencies
~46KB