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

Function Example_customHintsEnhanced

pkg/errors/examples_test.go:205–220  ·  view source on GitHub ↗

Example_customHintsEnhanced demonstrates adding custom hints to errors

()

Source from the content-addressed store, hash-verified

203
204// Example_customHintsEnhanced demonstrates adding custom hints to errors
205func 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
223func Example_allErrorCodes() {

Callers

nothing calls this directly

Calls 4

WithContextMethod · 0.95
WithHintMethod · 0.95
ErrorMethod · 0.95
NewErrorFunction · 0.92

Tested by

no test coverage detected