diff options
author | Gibheer <gibheer@gmail.com> | 2015-02-17 22:15:21 +0100 |
---|---|---|
committer | Gibheer <gibheer@gmail.com> | 2015-02-17 22:15:21 +0100 |
commit | a81c10357289a085170d6f3dadc2c6efd5794593 (patch) | |
tree | dd269d0ec299356a0b4be886501b3bd210a4d6cc /main.go | |
parent | 470d21409b5f26d49fefd34d75b82197045d4811 (diff) |
make error messages nicer
This changes the error message so that not the program help is printed
but instead the specific submenu help. This should result in much faster
and better understanding of the problematic situation.
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -48,18 +48,18 @@ func create_private_key() { fs.AddOutput() fs.AddPrivateKeyGenerationFlags() err := fs.Parse(program_args()) - if err != nil { crash_with_help(1, fmt.Sprintf("%s", err)) } + if err != nil { os.Exit(2) } var pk pki.Pemmer switch fs.Flags.PrivateKeyGenerationFlags.Type { case "ecdsa": pk, err = pki.NewPrivateKeyEcdsa(fs.Flags.PrivateKeyGenerationFlags.Curve) case "rsa": pk, err = pki.NewPrivateKeyRsa(fs.Flags.PrivateKeyGenerationFlags.Size) } - if err != nil { crash_with_help(2, fmt.Sprintf("%s", err)) } + if err != nil { os.Exit(2) } marsh_pem, err := pk.MarshalPem() - if err != nil { crash_with_help(2, fmt.Sprintf("%s", err)) } + if err != nil { os.Exit(2) } _, err = marsh_pem.WriteTo(fs.Flags.Output) - if err != nil { crash_with_help(2, fmt.Sprintf("%s", err)) } + if err != nil { os.Exit(2) } } // create a public key derived from a private key @@ -68,14 +68,14 @@ func create_public_key() { fs.AddPrivateKey() fs.AddOutput() err := fs.Parse(program_args()) - if err != nil { crash_with_help(1, fmt.Sprintf("%s", err)) } + if err != nil { os.Exit(2) } var pub_key pki.Pemmer pub_key = fs.Flags.PrivateKey.Public() marsh_pem, err := pub_key.MarshalPem() - if err != nil { crash_with_help(2, fmt.Sprintf("%s", err)) } + if err != nil { os.Exit(2) } _, err = marsh_pem.WriteTo(fs.Flags.Output) - if err != nil { crash_with_help(2, fmt.Sprintf("%s", err)) } + if err != nil { os.Exit(2) } } // print the module help |