v.vmod: return errors instead of panic-ing

pull/11213/head
Delyan Angelov 2021-08-16 16:54:41 +03:00
parent 0d30667ab5
commit 405ed584a1
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
1 changed files with 2 additions and 2 deletions

View File

@ -52,7 +52,7 @@ pub fn from_file(vmod_path string) ?Manifest {
if !os.exists(vmod_path) { if !os.exists(vmod_path) {
return error('v.mod: v.mod file not found.') return error('v.mod: v.mod file not found.')
} }
contents := os.read_file(vmod_path) or { panic('v.mod: cannot parse v.mod') } contents := os.read_file(vmod_path) or { '' }
return decode(contents) return decode(contents)
} }
@ -189,7 +189,7 @@ fn (mut p Parser) parse() ?Manifest {
tokens := p.scanner.tokens tokens := p.scanner.tokens
mut mn := Manifest{} mut mn := Manifest{}
if tokens[0].typ != .module_keyword { if tokens[0].typ != .module_keyword {
panic('not a valid v.mod') return error('vmod: v.mod files should start with Module')
} }
mut i := 1 mut i := 1
for i < tokens.len { for i < tokens.len {