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

Function Example_errorCodeProgrammaticHandling

pkg/errors/examples_test.go:137–154  ·  view source on GitHub ↗

Example_errorCodeProgrammaticHandling demonstrates using error codes for logic

()

Source from the content-addressed store, hash-verified

135
136// Example_errorCodeProgrammaticHandling demonstrates using error codes for logic
137func Example_errorCodeProgrammaticHandling() {
138 sql := "SELECT * FROM"
139 location := models.Location{Line: 1, Column: 14}
140
141 err := errors.IncompleteStatementError(location, sql)
142
143 // Check error type programmatically
144 if errors.IsCode(err, errors.ErrCodeIncompleteStatement) {
145 fmt.Println("Detected incomplete SQL statement")
146 fmt.Println("Error code:", errors.GetCode(err))
147 fmt.Println("Can suggest adding table name")
148 }
149
150 // Output:
151 // Detected incomplete SQL statement
152 // Error code: E2005
153 // Can suggest adding table name
154}
155
156// Example_unexpectedCharacter demonstrates unexpected character in SQL
157func Example_unexpectedCharacter() {

Callers

nothing calls this directly

Calls 3

IncompleteStatementErrorFunction · 0.92
IsCodeFunction · 0.92
GetCodeFunction · 0.92

Tested by

no test coverage detected