MCPcopy Create free account
hub / github.com/github/gh-aw / createTriggerParseError

Method createTriggerParseError

pkg/workflow/schedule_preprocessing.go:340–408  ·  view source on GitHub ↗

createTriggerParseError creates a detailed error for trigger parsing issues with source location

(filePath, content, triggerStr string, err error)

Source from the content-addressed store, hash-verified

338
339// createTriggerParseError creates a detailed error for trigger parsing issues with source location
340func (c *Compiler) createTriggerParseError(filePath, content, triggerStr string, err error) error {
341 schedulePreprocessingLog.Printf("Creating trigger parse error for: %s", triggerStr)
342
343 lines := strings.Split(content, "\n")
344
345 // Find the line where "on:" appears in the frontmatter
346 var onLine int
347 var onColumn int
348 inFrontmatter := false
349
350 for i, line := range lines {
351 lineNum := i + 1
352
353 // Check for frontmatter delimiter
354 if strings.TrimSpace(line) == "---" {
355 if !inFrontmatter {
356 inFrontmatter = true
357 } else {
358 // End of frontmatter
359 break
360 }
361 continue
362 }
363
364 if inFrontmatter {
365 // Look for "on:" field
366 trimmed := strings.TrimSpace(line)
367 if strings.HasPrefix(trimmed, "on:") {
368 onLine = lineNum
369 // Find the column where "on:" starts
370 onColumn = strings.Index(line, "on:") + 1
371 break
372 }
373 }
374 }
375
376 // If we found the line, create a formatted error
377 if onLine > 0 {
378 // Create context lines around the error
379 var context []string
380 startLine := max(1, onLine-2)
381 endLine := min(len(lines), onLine+2)
382
383 for i := startLine; i <= endLine; i++ {
384 if i-1 < len(lines) {
385 context = append(context, lines[i-1])
386 }
387 }
388
389 compilerErr := console.CompilerError{
390 Position: console.ErrorPosition{
391 File: filePath,
392 Line: onLine,
393 Column: onColumn,
394 },
395 Type: "error",
396 Message: "trigger syntax error: " + err.Error(),
397 Context: context,

Callers 1

Calls 4

FormatErrorFunction · 0.92
PrintfMethod · 0.45
ErrorMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected