mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
semver: add input information in error and panic output (#7712)
This commit is contained in:
parent
b1f16533b1
commit
7872b8d911
@ -74,11 +74,13 @@ fn parse_range(input string) ?Range {
|
||||
fn parse_comparator_set(input string) ?ComparatorSet {
|
||||
raw_comparators := input.split(comparator_sep)
|
||||
if raw_comparators.len > 2 {
|
||||
return error('Invalid format of comparator set')
|
||||
return error('Invalid format of comparator set for input "$input"')
|
||||
}
|
||||
mut comparators := []Comparator{}
|
||||
for raw_comp in raw_comparators {
|
||||
c := parse_comparator(raw_comp) or { return error('Invalid comparator: $raw_comp') }
|
||||
c := parse_comparator(raw_comp) or {
|
||||
return error('Invalid comparator "$raw_comp" in input "$input"')
|
||||
}
|
||||
comparators << c
|
||||
}
|
||||
return ComparatorSet{comparators}
|
||||
|
@ -26,7 +26,9 @@ pub fn from(input string) ?Version {
|
||||
return error('Empty input')
|
||||
}
|
||||
raw_version := parse(input)
|
||||
version := raw_version.validate() or { return error('Invalid version format') }
|
||||
version := raw_version.validate() or {
|
||||
return error('Invalid version format for input "$input"')
|
||||
}
|
||||
return version
|
||||
}
|
||||
|
||||
@ -69,7 +71,7 @@ pub fn (v1 Version) le(v2 Version) bool {
|
||||
|
||||
// * Utilites.
|
||||
pub fn coerce(input string) ?Version {
|
||||
ver := coerce_version(input) or { return error('Invalid version: $input') }
|
||||
ver := coerce_version(input) or { return error('Invalid version for input "$input"') }
|
||||
return ver
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ fn is_version_valid(input string) bool {
|
||||
[inline]
|
||||
fn coerce_version(input string) ?Version {
|
||||
raw_ver := parse(input)
|
||||
ver := raw_ver.coerce() or { return error('Invalid version: $input') }
|
||||
ver := raw_ver.coerce() or { return error('Invalid version for input "$input"') }
|
||||
return ver
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user