Skip to content

[BUG] CLI crashes with raw traceback on non-UTF-8 .dmai files #27

Description

@alphacrack

File: maithili_dsl/cli.py (run_dmai_file)

The file is read outside the try/except, so a .dmai file that is not valid UTF-8 crashes the CLI with a raw Python traceback instead of a friendly Maithili error:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

(Verified against v0.3.0 with a UTF-16-encoded file.)

Fix: wrap the read in try/except (UnicodeDecodeError, OSError), print a Maithili error message (see existing style, e.g. ⚠️ त्रुटि: फाइल UTF-8 में नहि अछि।), and return a non-zero exit code (reuse EXIT_NOT_FOUND or add EXIT_BAD_ENCODING = 7 and document it).

Tests: tests/test_cli.py — write a non-UTF8 temp file, assert exit code and no traceback.

Good first issue: small, contained, and a nice tour of the CLI error-handling style.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low priority: nice to havearea:climaithili_dsl/cli.py and sandboxbugSomething isn't workinggood first issueGood for newcomers

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions