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

Function Example_errorCodes

pkg/errors/example_test.go:69–88  ·  view source on GitHub ↗

Example_errorCodes demonstrates programmatic error handling

()

Source from the content-addressed store, hash-verified

67
68// Example_errorCodes demonstrates programmatic error handling
69func Example_errorCodes() {
70 sql := "SELECT * FROM"
71 location := models.Location{Line: 1, Column: 14}
72
73 // Create an error
74 err := errors.IncompleteStatementError(location, sql)
75
76 // Check error code programmatically
77 if errors.IsCode(err, errors.ErrCodeIncompleteStatement) {
78 fmt.Println("Detected incomplete SQL statement")
79 }
80
81 // Get error code
82 code := errors.GetCode(err)
83 fmt.Printf("Error code: %s\n", code)
84
85 // Output:
86 // Detected incomplete SQL statement
87 // Error code: E2005
88}
89
90// Example_contextExtraction demonstrates SQL context in error messages
91func Example_contextExtraction() {

Callers

nothing calls this directly

Calls 3

IncompleteStatementErrorFunction · 0.92
IsCodeFunction · 0.92
GetCodeFunction · 0.92

Tested by

no test coverage detected