word_counter: handle bad path

pull/679/head
Alexander Medvednikov 2019-06-26 18:01:31 +02:00
parent 69a363472f
commit 92ecd0ca7c
1 changed files with 4 additions and 1 deletions

View File

@ -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)