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)
| 32 | // |
| 33 | // Returns the formatted error string ready for display to end users. |
| 34 | func 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 |