-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: propagate version formatting errors #2566
Conversation
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.
I'm mostly curious about the error handling rationale; I personally would prefer that version formatting be fairly silent, if possible, but that might be a "just me" philosophy. Otherwise, it looks like you reordered parameters in a few places, but ... ¯_(ツ)_/¯ different strokes for different folks :)
|
||
match formatted { | ||
Ok(formatted) => Some(formatted), | ||
Err(error) => { |
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.
What conditions would lead to this warning? I would rather just silently format the raw version than log a warning when this happens.
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.
I would rather just silently format the raw version than log a warning when this happens.
This is silent unless you explicitly opt-in by setting STARSHIP_LOG
environment variable to the warn
level.
EDIT: warn
is default log level so it gets print always but that is actually a good thing if you ask me
What conditions would lead to this warning?
The simplest case that would cause an error is a malformed version format like:
version = "v${raw" # missing right curly
This results in (with logging enabled):
[WARN] - (starship::modules::java): Error formating `java` version:
--> 1:3
|
1 | v${raw
| ^---
|
= expected variable_name
As I explained above #2566 (comment) this is still silent. Error handling is moved to the upper level because version formatter doesn't know who called it thus can't print contextually rich warnings.
This speaks for itself ie I find the original version so good I didn't feel a need to change things around 😉 |
Actually, there is more than just that. I did 3 additional things there:
|
* refactor: propagate version formatting errors * refactor: trim version formatting boilerplate * refactor(node): unwrap version formatting * docs: fix typo * docs: remove dots after `version_format` * feat: lazy version parsing * refactor(version-formatter): collect segments into string
Description
Propagate errors originating from
VersionFormatter#format_version
to the upper level.Motivation and Context
Continuation of #2499
(It got closed before I managed to leave my review.)
Screenshots (if appropriate):
How Has This Been Tested?
Checklist:
/cc @offbyone