Example_customHintsEnhanced demonstrates adding custom hints to errors
()
| 203 | |
| 204 | // Example_customHintsEnhanced demonstrates adding custom hints to errors |
| 205 | func Example_customHintsEnhanced() { |
| 206 | sql := "SELECT * FROM users WHERE age > '18'" |
| 207 | location := models.Location{Line: 1, Column: 33} |
| 208 | |
| 209 | err := errors.NewError( |
| 210 | errors.ErrCodeInvalidSyntax, |
| 211 | "type mismatch in comparison", |
| 212 | location, |
| 213 | ) |
| 214 | err.WithContext(sql, 4) // Highlight '18' |
| 215 | err.WithHint("Age comparisons should use numeric values without quotes. Change '18' to 18") |
| 216 | |
| 217 | fmt.Println("Custom Hint Example:") |
| 218 | fmt.Println(err.Error()) |
| 219 | fmt.Println() |
| 220 | } |
| 221 | |
| 222 | // Example_allErrorCodes demonstrates all available error codes |
| 223 | func Example_allErrorCodes() { |
nothing calls this directly
no test coverage detected