New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
tools: improve error messages, add color coding and debug logging #19781
Conversation
a8b9e99
to
8f111f1
Compare
vpm_error(err.msg(), | ||
verbose: true | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is that formatted by vfmt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, vfmt doesn't behave when there is a call_expr before args that are part of a params struct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#19795 should fix it
Co-authored-by: JalonSolov <37967083+jalonsolov@users.noreply.github.com> Co-authored-by: Delyan Angelov <26967+jalonsolov@users.noreply.github.com>
This PR updates errors (e.g., also the error stated in yesterday's discord chat) and makes them uniform. It adds some color coding (similar to our regular V errors or cargo) and replaces verbose prints where they were solely used for debugging with debug logs that will be printed when run with the
VPM_DEBUG
env var.Errors:
Current
New
Logs:
Ofc. colors differ from the screenshots based on terminal configuration.
Also, the work on VPM implements new errors or extends existing ones. Updating them allows working with the new errors already, instead of creating ones that match the old ones, only to update them later.
馃 Generated by Copilot at a8b9e99
This pull request improves the error handling, logging, and output formatting of the
vpm
tool, using thelog
andterm
modules and some new helper functions. It also fixes some bugs and validations in the module metadata and dependency resolution features. It updates the test files to match the new output and error messages.馃 Generated by Copilot at a8b9e99
vpm_error
andvpm_log
tocommon.v
, and use them to replaceeprintln
,panic
, andverbose_println
in various places, respecting the verbosity settings and providing more details if needed (link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link)ErrorOptions
tocommon.v
, and use it to pass optional details and verbosity settings to thevpm_error
function, allowing more flexibility and control over how errors are displayed to the user (link)get_module_meta_info
function incommon.v
, where thecmd
variable was interpolated twice, causing an invalid command to be executed (link)get_module_meta_info
function incommon.v
, where it returns an error if the name is less than two characters long or does not start with a digit or a letter (link)get_module_meta_info
andresolve_dependencies
functions incommon.v
, where they are already interpolated with the${}
syntax (link,link)eprintln
function with thevpm_error
function in theget_mod_date_info
,get_all_modules
,ensure_vmodules_dir_exist
,increment_module_download_count
, andresolve_dependencies
functions incommon.v
, where they report various errors related to the retrieval, creation, and parsing of module data (link,link,link,link,link)eprintln
function with thevpm_error
function in thevalid_final_path_of_existing_module
function incommon.v
, where it reports various errors if the module name or path is invalid or unsupported, and make the error messages more consistent and informative (link)test_install_from_vmod
,test_install_from_git_url
,test_install_from_incomplete_url
functions ininstall_test.v
, and thetest_install_from_vmod
andtest_install_from_git_url
functions independency_test.v
, where they assert that the output of thev install
command contains the expected messages, and make the test output more consistent with the actual output of the vpm tool (link,link,link,link,link)test_install_from_incomplete_url
function ininstall_test.v
, where it asserts that the output of thev install
command contains the expected error message, and make the test more robust and flexible (link)vpm_search
function insearch.v
, where they are already interpolated with the${}
syntax (link)vpm_search
function insearch.v
, where they are already interpolated with the${}
syntax (link)vpm_search
function insearch.v
, where it prints a suggestion on how to install the module, and make the output more consistent with the actual output of the vpm tool (link)log
module insettings.v
, and use it for the newvpm_log
function that uses thelog
module to output debug messages (link)VPM_DEBUG
environment variable in theget_settings
function insettings.v
, where it sets the log level to debug if the variable is not empty (link)no_dl_count_increment
field in theget_settings
function insettings.v
, where it checks if theVPM_NO_INCREMENT
environment variable is not empty instead of equal to1
(link)vpm_log
function in themain
function invpm.v
, where it logs the parameters passed to the vpm tool, and provide more debug information for the vpm tool (link)eprintln
function with theprintln
function in themain
function invpm.v
, where it prints the list of outdated or installed modules, and avoid printing the list as an error (link,link)help.print_and_exit
function with thevpm_error
function and thehelp.print_and_exit
function in themain
function invpm.v
, where it reports an error and prints the help message if an unknown command is passed to the vpm tool, and make the code more consistent and concise (link)