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

Function Example_multiLineError

pkg/errors/examples_test.go:113–134  ·  view source on GitHub ↗

Example_multiLineError demonstrates error in multi-line SQL with proper context

()

Source from the content-addressed store, hash-verified

111
112// Example_multiLineError demonstrates error in multi-line SQL with proper context
113func Example_multiLineError() {
114 sql := `SELECT
115 u.id,
116 u.name,
117 u.email
118FROM users u
119JOIN orders o ON u.id = o.user_id
120WHERE u.age > 18.45.6
121AND o.total > 100`
122
123 location := models.Location{Line: 7, Column: 15}
124 err := errors.InvalidNumberError("18.45.6", location, sql)
125
126 fmt.Println("Multi-line SQL Error:")
127 fmt.Println(err.Error())
128 fmt.Println()
129
130 // Shows context with proper line numbering:
131 // Line 6: JOIN orders o ON u.id = o.user_id
132 // Line 7: WHERE u.age > 18.45.6 <- Error indicator here
133 // Line 8: AND o.total > 100
134}
135
136// Example_errorCodeProgrammaticHandling demonstrates using error codes for logic
137func Example_errorCodeProgrammaticHandling() {

Callers

nothing calls this directly

Calls 2

InvalidNumberErrorFunction · 0.92
ErrorMethod · 0.45

Tested by

no test coverage detected