Context
split_book.py, write_chunks (directory creation, open(...).write(...)) and main().
Problem
Confirmed crashes in #3 (NotADirectoryError / symlink OSError from shutil.rmtree) show that this code path has no exception handling at all around filesystem operations. The same lack of handling extends beyond rmtree to out_path.mkdir(...), open(file_path, "wb"), and writer.write(f) — any other OS-level failure here (permission denied, disk full, path too long, an unwritable device) would also propagate as a raw, unhandled traceback, unlike the rest of the tool (load_reader catches and reports its failures clearly).
This was not independently reproduced in this environment (the sandbox runs as root, which bypasses permission checks), but it's the same code path and the same missing-exception-handling root cause as the confirmed crashes in #3.
Expected
Filesystem operations in write_chunks/main's output-writing path are wrapped so OS-level failures produce a clear stderr message and exit code 1, consistent with load_reader's error handling.
Actual
No exception handling; any OS-level failure during output writing surfaces as a raw traceback.
Acceptance criteria
Context
split_book.py,write_chunks(directory creation,open(...).write(...)) andmain().Problem
Confirmed crashes in #3 (
NotADirectoryError/ symlinkOSErrorfromshutil.rmtree) show that this code path has no exception handling at all around filesystem operations. The same lack of handling extends beyondrmtreetoout_path.mkdir(...),open(file_path, "wb"), andwriter.write(f)— any other OS-level failure here (permission denied, disk full, path too long, an unwritable device) would also propagate as a raw, unhandled traceback, unlike the rest of the tool (load_readercatches and reports its failures clearly).This was not independently reproduced in this environment (the sandbox runs as root, which bypasses permission checks), but it's the same code path and the same missing-exception-handling root cause as the confirmed crashes in #3.
Expected
Filesystem operations in
write_chunks/main's output-writing path are wrapped so OS-level failures produce a clear stderr message and exit code 1, consistent withload_reader's error handling.Actual
No exception handling; any OS-level failure during output writing surfaces as a raw traceback.
Acceptance criteria
write_chunks(or its caller) catchesOSError/IOErroraround directory creation and file writes, converting them into clear, actionable stderr messages.