[PATCH aeolus-cli 4/9] fix known error code condition

Petr Blaho pblaho at redhat.com
Thu Dec 22 22:05:50 UTC 2011


From: Maros Zatko <mzatko at redhat.com>

---
 lib/aeolus_cli/command/base_command.rb |   74 ++++++++++++++++---------------
 1 files changed, 38 insertions(+), 36 deletions(-)

diff --git a/lib/aeolus_cli/command/base_command.rb b/lib/aeolus_cli/command/base_command.rb
index 47a9d2d..91ef445 100644
--- a/lib/aeolus_cli/command/base_command.rb
+++ b/lib/aeolus_cli/command/base_command.rb
@@ -99,48 +99,50 @@ module Aeolus
           code = "Argument Error"
           message = e.message
 
-        elsif e.is_a?(ActiveResource::ResourceNotFound)
-          code = "ResourceNotFound"
-          message = "Could not find resource"
+#        elsif e.is_a?(ActiveResource::ResourceNotFound)
+#          code = "ResourceNotFound"
+#          message = "Could not find resource"
 
         elsif e.respond_to?(:response)
           doc = Nokogiri::XML e.response.body
           code = doc.xpath("/error/code").text
           message = doc.xpath("/error/message").text
 
-          case code
-            when "BuildDeleteFailure"
-              message = "An error occured when deleting the Build from the Image Warehouse"
-            when "BuildNotFound"
-              message = "Could not find the specified Build"
-            when "ImageDeleteFailure"
-              message = "An error occured when deleting the Image from the Image Warehouse"
-            when "ImageNotFound"
-              message = "Could not find the specified Image"
-            when "InsufficientParametersSupplied"
-              message = "There were insufficient parameters provided in the request"
-            when "ParameterDataIncorrect"
-              message = "The given parameters are incorrect"
-            when "PushError"
-              message = "An error occured the Image Factory when trying to push"
-            when "ProviderAccountNotFound"
-              message = "Could not find the specified account"
-            when "ProviderImageDeleteFailure"
-              message = "An error occurd when deleting the Provider Image from Image Warehouse"
-            when "ProviderImageNotFound"
-              message = "Could not find the specified Provider Image"
-            when "ProviderImageStatusNotFound"
-              message = "There was no status supplied in the Provider Image"
-            when "TargetImageDeleteFailure"
-              message = "An error occured when deleting the Target Image from the Image Warehouse"
-            when "TargetImageNotFound"
-              message = "Could not locate the specified Target Image"
-            when "TargetImageStatusNotFound"
-              message = "There was no status supplied in the Target Image"
-            when "TargetNotFound"
-              message = "Could not locate the specified Target"
-            else
-              message = e.message
+          if message.to_s.empty?
+            case code
+              when "BuildDeleteFailure"
+                message = "An error occured when deleting the Build from the Image Warehouse"
+              when "BuildNotFound"
+                message = "Could not find the specified Build"
+              when "ImageDeleteFailure"
+                message = "An error occured when deleting the Image from the Image Warehouse"
+              when "ImageNotFound"
+                message = "Could not find the specified Image"
+              when "InsufficientParametersSupplied"
+                message = "There were insufficient parameters provided in the request"
+              when "ParameterDataIncorrect"
+                message = "The given parameters are incorrect"
+              when "PushError"
+                message = "An error occured the Image Factory when trying to push"
+              when "ProviderAccountNotFound"
+                message = "Could not find the specified account"
+              when "ProviderImageDeleteFailure"
+                message = "An error occurd when deleting the Provider Image from Image Warehouse"
+              when "ProviderImageNotFound"
+                message = "Could not find the specified Provider Image"
+              when "ProviderImageStatusNotFound"
+                message = "There was no status supplied in the Provider Image"
+              when "TargetImageDeleteFailure"
+                message = "An error occured when deleting the Target Image from the Image Warehouse"
+              when "TargetImageNotFound"
+                message = "Could not locate the specified Target Image"
+              when "TargetImageStatusNotFound"
+                message = "There was no status supplied in the Target Image"
+              when "TargetNotFound"
+                message = "Could not locate the specified Target"
+              else
+                message = e.message
+            end
           end
         else
           message = e.message + "\n" + (e.backtrace * "\n")
-- 
1.7.7.4




More information about the aeolus-devel mailing list