semver: add input information in error and panic output (#7712)
parent
b1f16533b1
commit
7872b8d911
|
@ -74,11 +74,13 @@ fn parse_range(input string) ?Range {
|
||||||
fn parse_comparator_set(input string) ?ComparatorSet {
|
fn parse_comparator_set(input string) ?ComparatorSet {
|
||||||
raw_comparators := input.split(comparator_sep)
|
raw_comparators := input.split(comparator_sep)
|
||||||
if raw_comparators.len > 2 {
|
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{}
|
mut comparators := []Comparator{}
|
||||||
for raw_comp in raw_comparators {
|
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
|
comparators << c
|
||||||
}
|
}
|
||||||
return ComparatorSet{comparators}
|
return ComparatorSet{comparators}
|
||||||
|
|
|
@ -26,7 +26,9 @@ pub fn from(input string) ?Version {
|
||||||
return error('Empty input')
|
return error('Empty input')
|
||||||
}
|
}
|
||||||
raw_version := parse(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
|
return version
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +71,7 @@ pub fn (v1 Version) le(v2 Version) bool {
|
||||||
|
|
||||||
// * Utilites.
|
// * Utilites.
|
||||||
pub fn coerce(input string) ?Version {
|
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
|
return ver
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ fn is_version_valid(input string) bool {
|
||||||
[inline]
|
[inline]
|
||||||
fn coerce_version(input string) ?Version {
|
fn coerce_version(input string) ?Version {
|
||||||
raw_ver := parse(input)
|
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
|
return ver
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue