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

Function FormatErrorWithContextAt

pkg/errors/formatter.go:57–67  ·  view source on GitHub ↗

FormatErrorWithContextAt creates a structured error for the given code and location, attaches the SQL context window, and auto-generates a hint. It then returns the fully-formatted error string. This is useful for one-shot error formatting without retaining the *Error value. Parameters: - code: Err

(code ErrorCode, message string, location models.Location, sql string, highlightLen int)

Source from the content-addressed store, hash-verified

55//
56// Returns the complete formatted error string including context highlighting.
57func FormatErrorWithContextAt(code ErrorCode, message string, location models.Location, sql string, highlightLen int) string {
58 err := NewError(code, message, location)
59 err = err.WithContext(sql, highlightLen)
60
61 // Auto-generate hints
62 if hint := GenerateHint(code, "", ""); hint != "" {
63 err = err.WithHint(hint)
64 }
65
66 return err.Error()
67}
68
69// FormatMultiLineContext formats an SQL context window around a specific error location.
70// It shows up to three lines: one before the error, the error line itself, and one

Callers 1

Calls 5

WithContextMethod · 0.95
WithHintMethod · 0.95
ErrorMethod · 0.95
GenerateHintFunction · 0.85
NewErrorFunction · 0.70

Tested by 1