mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
builtin: change IError msg and code to methods + fix vlib, add a deprecation notice for the old usages (#13041)
This commit is contained in:
@@ -29,14 +29,8 @@ struct Range {
|
||||
comparator_sets []ComparatorSet
|
||||
}
|
||||
|
||||
struct InvalidComparatorCountError {
|
||||
msg string
|
||||
code int
|
||||
}
|
||||
|
||||
struct InvalidComparatorFormatError {
|
||||
msg string
|
||||
code int
|
||||
MessageError
|
||||
}
|
||||
|
||||
fn (r Range) satisfies(ver Version) bool {
|
||||
|
||||
@@ -20,13 +20,20 @@ pub enum Increment {
|
||||
}
|
||||
|
||||
struct EmptyInputError {
|
||||
msg string = 'Empty input'
|
||||
code int
|
||||
Error
|
||||
}
|
||||
|
||||
pub fn (err EmptyInputError) msg() string {
|
||||
return 'Empty input'
|
||||
}
|
||||
|
||||
struct InvalidVersionFormatError {
|
||||
msg string
|
||||
code int
|
||||
Error
|
||||
input string
|
||||
}
|
||||
|
||||
pub fn (err InvalidVersionFormatError) msg() string {
|
||||
return 'Invalid version format for input "$err.input"'
|
||||
}
|
||||
|
||||
// * Constructor.
|
||||
@@ -38,7 +45,7 @@ pub fn from(input string) ?Version {
|
||||
raw_version := parse(input)
|
||||
version := raw_version.validate() or {
|
||||
return IError(&InvalidVersionFormatError{
|
||||
msg: 'Invalid version format for input "$input"'
|
||||
input: input
|
||||
})
|
||||
}
|
||||
return version
|
||||
|
||||
Reference in New Issue
Block a user