From 405ed584a10d3b69110f58754e2c035cee3f0499 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Mon, 16 Aug 2021 16:54:41 +0300 Subject: [PATCH] v.vmod: return errors instead of panic-ing --- vlib/v/vmod/parser.v | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vlib/v/vmod/parser.v b/vlib/v/vmod/parser.v index c96afeedc9..0eeb580e95 100644 --- a/vlib/v/vmod/parser.v +++ b/vlib/v/vmod/parser.v @@ -52,7 +52,7 @@ pub fn from_file(vmod_path string) ?Manifest { if !os.exists(vmod_path) { 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) } @@ -189,7 +189,7 @@ fn (mut p Parser) parse() ?Manifest { tokens := p.scanner.tokens mut mn := Manifest{} 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 for i < tokens.len {