MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / WithContext

Method WithContext

pkg/errors/errors.go:367–376  ·  view source on GitHub ↗

WithContext adds SQL context to the error. Attaches SQL source code context with highlighting information for visual error display. The context shows surrounding lines and highlights the specific location of the error. Parameters: - sql: Original SQL source code - highlightLen: Number of character

(sql string, highlightLen int)

Source from the content-addressed store, hash-verified

365//
366// Note: WithContext modifies the error in-place and returns it for chaining.
367func (e *Error) WithContext(sql string, highlightLen int) *Error {
368 e.Context = &ErrorContext{
369 SQL: sql,
370 StartLine: e.Location.Line,
371 EndLine: e.Location.Line,
372 HighlightCol: e.Location.Column,
373 HighlightLen: highlightLen,
374 }
375 return e
376}
377
378// WithHint adds a suggestion hint to the error.
379//

Callers 15

TestError_WithContextFunction · 0.95
TestError_FormatContextFunction · 0.95
FormatErrorWithContextAtFunction · 0.95
FormatErrorWithExampleFunction · 0.95
Example_customHintsFunction · 0.95
UnexpectedCharErrorFunction · 0.45
UnterminatedStringErrorFunction · 0.45

Calls

no outgoing calls

Tested by 7

TestError_WithContextFunction · 0.76
TestError_FormatContextFunction · 0.76
Example_customHintsFunction · 0.76