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

Function FormatErrorWithContext

pkg/errors/formatter.go:34–42  ·  view source on GitHub ↗

FormatErrorWithContext formats an error with SQL context and visual indicators. For *Error values it delegates to the structured Error.Error() method, which includes code, location, SQL context highlighting, hint, and help URL. For all other error types it falls back to a plain "Error: " st

(err error, sql string)

Source from the content-addressed store, hash-verified

32//
33// Returns the formatted error string ready for display to end users.
34func FormatErrorWithContext(err error, sql string) string {
35 // If it's already a structured error, just return its formatted string
36 if structErr, ok := err.(*Error); ok {
37 return structErr.Error()
38 }
39
40 // For non-structured errors, return simple format
41 return fmt.Sprintf("Error: %v", err)
42}
43
44// FormatErrorWithContextAt creates a structured error for the given code and location,
45// attaches the SQL context window, and auto-generates a hint. It then returns the

Callers 2

Calls 1

ErrorMethod · 0.45

Tested by 2