1
0
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:
Larpon 2020-12-30 17:07:21 +01:00 committed by GitHub
parent b1f16533b1
commit 7872b8d911
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 5 deletions

View File

@ -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}

View File

@ -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
}

View File

@ -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
}