-
-
Notifications
You must be signed in to change notification settings - Fork 595
Description
*** THE BUG ****
The CLI module contains multiple unwrap() calls that can cause the application to crash on recoverable errors instead of handling them gracefully. When operations such as file reading, network requests, or parsing encounter errors, the application panics rather than providing proper error messages or graceful fallbacks.
****REPRODUCTION *****
Steps to reproduce the issue:
Run the Boa CLI with a malformed JavaScript file.
Run the CLI with a file that has insufficient permissions.
Run the CLI with a file that does not exist.
The application will crash with a panic instead of displaying a proper error message.
Example scenario:
This will crash if the file doesn't exist or has syntax errors
./boa nonexistent-file.js
Expected behavior
Instead of crashing with a panic, the application should handle errors gracefully by:
Providing informative error messages to the user.
Returning appropriate exit codes.
Continuing execution where appropriate.
Avoiding unexpected termination on recoverable errors.
The application should properly handle file I/O errors, parsing errors, and other recoverable conditions without crashing.
Build environment (please complete the following information):
OS: Any
Version: All versions
Target triple: All targets
Rustc version: All versions
Additional context
This issue negatively impacts the robustness and user experience of the CLI tool. Using unwrap() for error handling in production code is inappropriate because it leads to crashes on recoverable errors.
The fix involves replacing unwrap() calls with proper error handling using the ? operator or implementing appropriate error recovery mechanisms throughout the CLI module.
Known locations where unwrap() is used include:
File reading operations in cli/src/main.rs
Network request handling
Parsing operations that may encounter malformed input
Addressing this issue would align the project with Rust best practices for error handling and significantly improve the overall reliability of the application.