On 26/01/12 18:32 +0100, Maros Zatko wrote:
On 01/26/2012 06:10 PM, mtaylor(a)redhat.com wrote:
>From: Martyn Taylor<mtaylor(a)redhat.com>
>
>---
> lib/aeolus_cli/command/base_command.rb | 4 ++++
> 1 files changed, 4 insertions(+), 0 deletions(-)
>
>diff --git a/lib/aeolus_cli/command/base_command.rb
b/lib/aeolus_cli/command/base_command.rb
>index 48e8eb5..83db176 100644
>--- a/lib/aeolus_cli/command/base_command.rb
>+++ b/lib/aeolus_cli/command/base_command.rb
>@@ -87,6 +87,10 @@ module Aeolus
> private
> def handle_exception(e)
>
>+ if e.is_a?(Errno::ECONNREFUSED)
>+ code = "Connection Refused"
>+ message = "Could not connect to aeolus-conductor please make sure it
is running and that ~/.aeolus-cli points to the conductor API URL"
>+
> if e.is_a?(ActiveResource::UnauthorizedAccess)
> code = "Unauthorized"
> message = "Invalid Credentials, please check ~/.aeolus-cli"
it's missing end or elsif, i'm getting syntax errors, please add elsif
on line 94
otherwise ACK
This is more a forward-looking suggestion, but I wanted to mention it
now, while it crossed my mind. I think this whole monster if/else
(and nested case statement) can/should be reworked to simply pass the
error into a hash and set the code/message based on the matching
values there. This would obviate the need for any conditional logic
as well as make the code more succint and separate the messages into
something more easily internationalized later on as needed. The same
could be done with the default messages. I would suggest some
combination of a begin/rescue block with possibly a method_missing to
do the right thing here. I'll put a feature into redmine for this to
be improved later, just wanted to toss the idea out. I saw this once
before and meant to suggest something, but didnt do it quickly enough
and promptly forgot.
-j