mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
semver: add custom errors (#9493)
This commit is contained in:
parent
cabbf93faa
commit
89082de5d1
3 changed files with 51 additions and 6 deletions
20
examples/errors.v
Normal file
20
examples/errors.v
Normal file
|
@ -0,0 +1,20 @@
|
|||
import semver
|
||||
|
||||
fn main() {
|
||||
semver.from('asd') or { check_error(err) }
|
||||
semver.from('') or { check_error(err) }
|
||||
}
|
||||
|
||||
fn check_error(err IError) {
|
||||
match err {
|
||||
semver.InvalidVersionFormatError {
|
||||
println('wrong format')
|
||||
}
|
||||
semver.EmptyInputError {
|
||||
println('empty input')
|
||||
}
|
||||
else {
|
||||
println('unknown error')
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue