builtin: change IError msg and code to methods + fix vlib, add a deprecation notice for the old usages (#13041)

This commit is contained in:
Tim Basel 2022-02-11 14:52:33 +01:00 committed by GitHub
parent 61024d4b75
commit 9d0a5942ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
80 changed files with 493 additions and 324 deletions

View file

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