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

Function FormatErrorList

pkg/errors/formatter.go:202–217  ·  view source on GitHub ↗

FormatErrorList formats a slice of structured errors into a numbered list with full context for each entry. The output begins with a count line and separates each error with a blank line. Returns "No errors" when the slice is empty. Parameters: - errors: Slice of *Error values to format Returns t

(errors []*Error)

Source from the content-addressed store, hash-verified

200//
201// Returns the multi-error report string.
202func FormatErrorList(errors []*Error) string {
203 if len(errors) == 0 {
204 return "No errors"
205 }
206
207 var sb strings.Builder
208 sb.WriteString(fmt.Sprintf("Found %d error(s):\n\n", len(errors)))
209
210 for i, err := range errors {
211 sb.WriteString(fmt.Sprintf("Error %d:\n", i+1))
212 sb.WriteString(err.Error())
213 sb.WriteString("\n\n")
214 }
215
216 return sb.String()
217}
218
219// FormatErrorWithExample formats an error and appends a side-by-side "Wrong / Correct"
220// example to the hint. This is particularly useful for educational error messages

Callers 1

TestFormatErrorListFunction · 0.85

Calls 2

ErrorMethod · 0.45
StringMethod · 0.45

Tested by 1

TestFormatErrorListFunction · 0.68