comparison multipass-add.go @ 7:406d3cd76739

Report errors to the user.
author Paul Fisher <paul@pfish.zone>
date Sat, 24 Oct 2015 23:40:13 -0400
parents a4fa4f28b472
children 1246b4b9028b
comparison
equal deleted inserted replaced
6:10613f0f4737 7:406d3cd76739
16 reader := bufio.NewReader(os.Stdin) 16 reader := bufio.NewReader(os.Stdin)
17 fmt.Print("Describe password: ") 17 fmt.Print("Describe password: ")
18 text, err := reader.ReadString('\n') 18 text, err := reader.ReadString('\n')
19 if err != nil { 19 if err != nil {
20 fmt.Println(err.Error()) 20 fmt.Println(err.Error())
21 return 21 os.Exit(1)
22 } 22 }
23 text = text[:len(text)-1] 23 text = text[:len(text)-1]
24 entry, password, err := auth.NewEntry(text) 24 entry, password, err := auth.NewEntry(text)
25 if err != nil { 25 if err != nil {
26 fmt.Println(err.Error()) 26 fmt.Println(err.Error())
27 return 27 os.Exit(1)
28 } 28 }
29 passfile.Add(entry) 29 err = passfile.Add(entry)
30 if err != nil {
31 fmt.Println("Couldn't create a password:")
32 fmt.Println(err.Error())
33 os.Exit(1)
34 }
30 fmt.Printf("New password: %s\n", password) 35 fmt.Printf("New password: %s\n", password)
31 } 36 }