This document describes the comprehensive error handling implemented in the llms-txt-generator action.
- Location:
main.tslines 73-82 - Implementation:
- Validates that input directory exists
- Validates that input path is actually a directory (not a file)
- Provides clear error message with absolute path
- Location:
main.tslines 95-97 - Implementation:
- Validates at least one markdown file was found
- Includes exclude pattern in error message if applicable
- Provides clear error message with directory path
- Location:
main.tslines 103-116 - Implementation:
- Wraps individual file parsing in try-catch
- Logs warning for each failed file with specific error message
- Continues processing remaining files
- Tracks count of failed files
- Provides summary of parsing results
- Location:
main.tslines 130-137 andgenerator.tslines 109-145 - Implementation:
- Validates output directory can be created
- Validates llms.txt can be written
- Validates llms-full.txt can be written
- Provides specific error messages for each failure type
- Includes permission hints in error messages
- Location:
main.tslines 157-167 - Implementation:
- Catches all unhandled errors in main try-catch
- Logs error message using
core.error() - Logs stack trace using
core.debug()for debugging - Sets action status to failed using
core.setFailed()
- Base URL Format: Validates base URL is a valid URL format
- Required Inputs: Validates base-url and project-name are not empty
- Sections JSON: Validates sections input is valid JSON object
- Location:
main.tslines 88-92 - Implementation: Wraps file scanner call in try-catch with descriptive error
- Location:
main.tslines 121-127 - Implementation: Wraps content generation in try-catch with descriptive error
All error messages follow these principles:
- Descriptive: Clearly state what went wrong
- Actionable: Provide hints on how to fix the issue
- Contextual: Include relevant paths, patterns, or values
- Consistent: Use similar formatting and structure
Error: Input directory does not exist: /path/to/directory
Error: No markdown files found in directory: /path/to/directory (exclude pattern: **/node_modules/**)
Warning: Failed to parse file docs/example.md: ENOENT: no such file or directory
Error: No markdown files could be successfully parsed. All 5 file(s) failed.
Error: Failed to write output files to /path/to/output: EACCES: permission denied. Check directory permissions.
To verify error handling, test these scenarios:
- Non-existent input directory
- Empty directory with no markdown files
- Directory with only excluded files
- Corrupted markdown files
- Read-only output directory
- Invalid base URL format
- Invalid sections JSON
- Mixed success/failure file parsing