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

Function Example_enhancedErrorWithContext

pkg/errors/examples_test.go:25–43  ·  view source on GitHub ↗

Example_enhancedErrorWithContext demonstrates the enhanced error formatting with 3 lines of context

()

Source from the content-addressed store, hash-verified

23
24// Example_enhancedErrorWithContext demonstrates the enhanced error formatting with 3 lines of context
25func Example_enhancedErrorWithContext() {
26 // Multi-line SQL with an error on line 3
27 sql := `SELECT id, name, email
28FROM users
29WHERE age > 18.45.6
30ORDER BY name`
31
32 location := models.Location{Line: 3, Column: 13}
33 err := errors.InvalidNumberError("18.45.6", location, sql)
34
35 fmt.Println("Enhanced Error Output:")
36 fmt.Println(err.Error())
37 fmt.Println()
38
39 // Note: This will show:
40 // - Line 2 (FROM users)
41 // - Line 3 (WHERE age > 18.45.6) with error indicator
42 // - Line 4 (ORDER BY name)
43}
44
45// Example_typoDetectionWithSuggestions demonstrates automatic typo detection
46func Example_typoDetectionWithSuggestions() {

Callers

nothing calls this directly

Calls 2

InvalidNumberErrorFunction · 0.92
ErrorMethod · 0.45

Tested by

no test coverage detected