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

Function FormatErrorWithSuggestion

pkg/errors/formatter.go:176–190  ·  view source on GitHub ↗

FormatErrorWithSuggestion creates and formats a structured error that includes a manually provided hint. When suggestion is empty, the function falls back to auto-generating a hint via GenerateHint. This is the preferred formatter when the caller already knows the correct fix. Parameters: - code: E

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

Source from the content-addressed store, hash-verified

174//
175// Returns the complete formatted error string.
176func FormatErrorWithSuggestion(code ErrorCode, message string, location models.Location, sql string, highlightLen int, suggestion string) string {
177 err := NewError(code, message, location)
178 err = err.WithContext(sql, highlightLen)
179
180 if suggestion != "" {
181 err = err.WithHint(suggestion)
182 } else {
183 // Try to auto-generate suggestion
184 if autoHint := GenerateHint(code, "", ""); autoHint != "" {
185 err = err.WithHint(autoHint)
186 }
187 }
188
189 return err.Error()
190}
191
192// FormatErrorList formats a slice of structured errors into a numbered list with
193// full context for each entry. The output begins with a count line and separates

Callers 1

Calls 5

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

Tested by 1