From 92ecd0ca7c262361618fbc725713b80cafaa592e Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Wed, 26 Jun 2019 18:01:31 +0200 Subject: [PATCH] word_counter: handle bad path --- examples/word_counter/word_counter.v | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/word_counter/word_counter.v b/examples/word_counter/word_counter.v index a8f39c7823..8b913f5dd9 100644 --- a/examples/word_counter/word_counter.v +++ b/examples/word_counter/word_counter.v @@ -13,7 +13,10 @@ fn main() { else { path = os.args[1] } - contents := os.read_file(path.trim_space()) + contents := os.read_file(path.trim_space()) or { + println('failed to open $path') + return + } mut m := map[string]int{} for word in contents.to_lower().split(' ') { key := filter_word(word)