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

Function Example_contextExtraction

pkg/errors/example_test.go:91–107  ·  view source on GitHub ↗

Example_contextExtraction demonstrates SQL context in error messages

()

Source from the content-addressed store, hash-verified

89
90// Example_contextExtraction demonstrates SQL context in error messages
91func Example_contextExtraction() {
92 // Multi-line SQL with error on line 2
93 sql := `SELECT *
94FROM users
95WHERE age > 18.45.6
96ORDER 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
110func Example_chainedErrors() {

Callers

nothing calls this directly

Calls 1

InvalidNumberErrorFunction · 0.92

Tested by

no test coverage detected