From f013359a449c458fe3f0a2bd9b5dd21d9da3ee2c Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Sun, 18 Aug 2019 17:57:57 +0300 Subject: [PATCH] compiler: improve error handling for 'v install' --- compiler/main.v | 13 +++++++++---- tools/vget.v | 21 ++++++++++++++++++--- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/compiler/main.v b/compiler/main.v index e49686bc0c..d4bff60ac0 100644 --- a/compiler/main.v +++ b/compiler/main.v @@ -141,13 +141,18 @@ fn main() { if true { //println('Building vget...') os.chdir(vroot + '/tools') - _ := os.exec('$vexec -o $vget vget.v') or { + vgetcompilation := os.exec('$vexec -o $vget vget.v') or { panic(err) } + if vgetcompilation.exit_code != 0 { + panic( vgetcompilation.output ) + } } - - _ := os.exec('$vget ' + names.join(' ')) or { - panic(err) + vgetresult := os.exec('$vget ' + names.join(' ')) or { + panic(err) + } + if vgetresult.exit_code != 0 { + panic( vgetresult.output ) } return } diff --git a/tools/vget.v b/tools/vget.v index 3e43dff1dd..0fa1718d72 100644 --- a/tools/vget.v +++ b/tools/vget.v @@ -35,17 +35,32 @@ fn main() { mut errors := 0 names := os.args.slice(1, os.args.len) 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 { errors++ - println('Error. Make sure you are online.') + println('Skipping module "$name", since its information is not in json format.') continue } if( '' == mod.url || '' == mod.name ){ errors++ // 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 }