-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patherrors.go
More file actions
50 lines (43 loc) · 1.66 KB
/
Copy patherrors.go
File metadata and controls
50 lines (43 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright 2026 TypeFox GmbH
// This program and the accompanying materials are made available under the
// terms of the MIT License, which is available in the project root.
package fastbelt
// A ReferenceError reports a failure while resolving a cross-reference.
// It is converted to diagnostics during linking.
type ReferenceError struct {
// Msg is the human-readable error message shown in diagnostics.
Msg string
// Severity is an LSP-compatible [DiagnosticSeverity] value.
// Use [SeverityError], [SeverityWarning], [SeverityInfo], or [SeverityHint].
Severity int
}
// NewReferenceError returns a [ReferenceError] with [SeverityError].
func NewReferenceError(msg string) *ReferenceError {
return &ReferenceError{Msg: msg, Severity: 1}
}
// A ParserError describes a syntax error detected by the parser.
type ParserError struct {
// Msg is the parser diagnostic message.
Msg string
// Token is the token this error is associated with.
// It is nil when the parser error refers to unexpected end of input.
Token *Token
}
// NewParserError returns a [ParserError] for msg at token.
func NewParserError(msg string, token *Token) *ParserError {
return &ParserError{Msg: msg, Token: token}
}
// A LexerError describes invalid input encountered during tokenization.
type LexerError struct {
// Msg is the lexer diagnostic message.
Msg string
// Range is the byte-offset range of the invalid input in the source text.
Range TextRange
}
// NewLexerError returns a [LexerError] for msg and the offending text range.
func NewLexerError(msg string, startOffset, endOffset int) *LexerError {
return &LexerError{
Msg: msg,
Range: NewTextRange(startOffset, endOffset),
}
}