> + System.err.println("Cannot open your SSH public key at " +
> sshPublicKeyFileName
> + + "\nIt is required to authorize your access to the
> machine.\n"
> + + "See
> https://developers.google.com/compute/docs/instances#sshkeys for more
> details.\n"
> + + e.getMessage());
> + System.exit(1);
> + }
> + String sshPrivateKeyFileName = System.getProperty("user.home") +
> "/.ssh/google_compute_engine";
> + String sshPrivateKey = null;
> + try {
> + sshPrivateKey = Files.toString(new File(sshPrivateKeyFileName),
> Charset.defaultCharset());
> + } catch (IOException e) {
> + System.err.println("Cannot open your SSH private key at " +
> sshPrivateKeyFileName
> + + "\nIt is required to perform any operations on your
> machine via SSH.\n"
> + + "See
> https://developers.google.com/compute/docs/instances#sshkeys for more
> details.\n"
> + + e.getMessage());
> + System.exit(1);
> This is why I decided to keep these try blocks separate.
Fair point - they are a little different, indeed. I was just wondering if there
was some way to reduce the amount of code duplication we now have for just a
slight difference in error messages. How about putting them in _one_ block with
a message such as: "Unable to load your SSH keys. Please ensure your public
key, used for X, is at ... and your private key, needed for Y, is at ..."?
But also OK to leave as-is - your call.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/63/files#r17212126