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:
parent
d373b331fa
commit
f013359a44
@ -141,13 +141,18 @@ 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 )
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
vgetresult := os.exec('$vget ' + names.join(' ')) or {
|
||||||
_ := os.exec('$vget ' + names.join(' ')) or {
|
panic(err)
|
||||||
panic(err)
|
}
|
||||||
|
if vgetresult.exit_code != 0 {
|
||||||
|
panic( vgetresult.output )
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
21
tools/vget.v
21
tools/vget.v
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user