semver: add custom errors (#9493)

This commit is contained in:
Atakan Yenel 2021-03-29 11:17:00 +02:00 committed by GitHub
parent cabbf93faa
commit 89082de5d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 51 additions and 6 deletions

20
examples/errors.v Normal file
View 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')
}
}
}