1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

compiler: improve error handling for 'v install'

This commit is contained in:
Delyan Angelov 2019-08-18 17:57:57 +03:00 committed by Alexander Medvednikov
parent d373b331fa
commit f013359a44
2 changed files with 27 additions and 7 deletions

View File

@ -141,14 +141,19 @@ fn main() {
if true { if true {
//println('Building vget...') //println('Building vget...')
os.chdir(vroot + '/tools') os.chdir(vroot + '/tools')
_ := os.exec('$vexec -o $vget vget.v') or { vgetcompilation := os.exec('$vexec -o $vget vget.v') or {
panic(err) panic(err)
} }
if vgetcompilation.exit_code != 0 {
panic( vgetcompilation.output )
} }
}
_ := os.exec('$vget ' + names.join(' ')) or { vgetresult := os.exec('$vget ' + names.join(' ')) or {
panic(err) panic(err)
} }
if vgetresult.exit_code != 0 {
panic( vgetresult.output )
}
return return
} }
// TODO quit if the compiler is too old // TODO quit if the compiler is too old

View File

@ -35,17 +35,32 @@ fn main() {
mut errors := 0 mut errors := 0
names := os.args.slice(1, os.args.len) names := os.args.slice(1, os.args.len)
for name in names { for name in names {
s := http.get_text(url + '/jsmod/$name') modurl := url + '/jsmod/$name'
r := http.get(modurl) or { panic(err) }
if r.status_code == 404 {
println('Skipping module "$name", since $url reported that "$name" does not exist.')
errors++
continue
}
if r.status_code != 200 {
println('Skipping module "$name", since $url responded with $r.status_code http status code. Please try again later.')
errors++
continue
}
s := r.text
mod := json.decode(Mod, s) or { mod := json.decode(Mod, s) or {
errors++ errors++
println('Error. Make sure you are online.') println('Skipping module "$name", since its information is not in json format.')
continue continue
} }
if( '' == mod.url || '' == mod.name ){ if( '' == mod.url || '' == mod.name ){
errors++ errors++
// a possible 404 error, which means a missing module? // a possible 404 error, which means a missing module?
println('Skipping module "$name", since it does not exist.') println('Skipping module "$name", since it is missing name or url information.')
continue continue
} }