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

Function NewError

pkg/errors/errors.go:335–342  ·  view source on GitHub ↗

NewError creates a new structured error. Factory function for creating GoSQLX errors with error code, message, and location. This is the primary way to create errors in the library. Parameters: - code: ErrorCode for programmatic error handling (E1xxx-E4xxx) - message: Human-readable error descript

(code ErrorCode, message string, location models.Location)

Source from the content-addressed store, hash-verified

333//
334// err = err.WithContext(sqlSource, 1).WithHint("Expected FROM keyword")
335func NewError(code ErrorCode, message string, location models.Location) *Error {
336 return &Error{
337 Code: code,
338 Message: message,
339 Location: location,
340 HelpURL: fmt.Sprintf("https://github.com/ajitpratap0/GoSQLX/blob/main/docs/ERROR_CODES.md#%s", code),
341 }
342}
343
344// WithContext adds SQL context to the error.
345//

Callers 15

Example_errorChainingFunction · 0.92
Example_chainedErrorsFunction · 0.92
Example_customHintsFunction · 0.92
TestFormatErrorSummaryFunction · 0.70
TestFormatErrorListFunction · 0.70
TestIsStructuredErrorFunction · 0.70
TestExtractLocationFunction · 0.70
TestExtractErrorCodeFunction · 0.70

Calls

no outgoing calls

Tested by 15

Example_errorChainingFunction · 0.74
Example_chainedErrorsFunction · 0.74
Example_customHintsFunction · 0.74
TestFormatErrorSummaryFunction · 0.56
TestFormatErrorListFunction · 0.56
TestIsStructuredErrorFunction · 0.56
TestExtractLocationFunction · 0.56
TestExtractErrorCodeFunction · 0.56