Example_contextExtraction demonstrates SQL context in error messages
()
| 89 | |
| 90 | // Example_contextExtraction demonstrates SQL context in error messages |
| 91 | func Example_contextExtraction() { |
| 92 | // Multi-line SQL with error on line 2 |
| 93 | sql := `SELECT * |
| 94 | FROM users |
| 95 | WHERE age > 18.45.6 |
| 96 | ORDER BY name` |
| 97 | |
| 98 | location := models.Location{Line: 3, Column: 13} |
| 99 | err := errors.InvalidNumberError("18.45.6", location, sql) |
| 100 | |
| 101 | // Error includes: |
| 102 | // - The problematic line from the SQL |
| 103 | // - Position indicator pointing to the error |
| 104 | // - Helpful hint about numeric format |
| 105 | fmt.Println("Error detected in multi-line SQL:") |
| 106 | _ = err // Use the error |
| 107 | } |
| 108 | |
| 109 | // Example_chainedErrors demonstrates error wrapping |
| 110 | func Example_chainedErrors() { |
nothing calls this directly
no test coverage detected