Skip to content

Better error messages when code generation fails or finds no modules #132

@bbopen

Description

@bbopen

Problem

When generation fails (e.g., Python can't import a module), the output is misleading:

$ npx tywrap generate
Generated:

No error, no indication of what went wrong. This is very confusing for users trying to debug their setup.

Expected Behavior

Clear error messages explaining what failed:

$ npx tywrap generate
Error: Could not import module 'my_module'
  - Module not found in Python path
  - Current PYTHONPATH: /usr/lib/python3.11
  - Hint: Set PYTHONPATH to include your local modules, e.g.:
    PYTHONPATH=./python npx tywrap generate

Generated: 0 files (0 modules found)

Proposed Changes

  1. Report import failures - When Python fails to import a configured module, show the error
  2. Show summary stats - "Generated: 3 files from 2 modules" instead of just "Generated:"
  3. Warn on empty output - If no modules were found/generated, warn explicitly
  4. Add --verbose flag - For detailed debugging output during generation
  5. Validate config early - Check that configured modules can be imported before starting generation

Labels

enhancement, developer-experience, error-handling

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions