Rather than combining a slew of exceptions with .join(', '), this
adds support for showing an unsorted list of errors, and uses
this to display deployment errors.
Resolves
https://bugzilla.redhat.com/show_bug.cgi?id=770377
---
src/app/models/deployment.rb | 6 +++---
src/app/models/instance.rb | 1 -
src/app/views/layouts/_new_notification.html.haml | 4 ++--
src/lib/exceptions.rb | 16 ++++++++++++++++
4 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/src/app/models/deployment.rb b/src/app/models/deployment.rb
index 9b57ecc..784424a 100644
--- a/src/app/models/deployment.rb
+++ b/src/app/models/deployment.rb
@@ -322,7 +322,7 @@ class Deployment < ActiveRecord::Base
# we try to create an instance for each assembly and check
# if a match is found
def check_assemblies_matches(user)
- errs = {}
+ errs = []
deployable_xml.assemblies.each do |assembly|
begin
hw_profile = permissioned_frontend_hwprofile(user, assembly.hwp)
@@ -341,10 +341,10 @@ class Deployment < ActiveRecord::Base
)
possibles, errors = instance.matches
if possibles.empty? and not errors.empty?
- raise errors.join(", ")
+ raise
Aeolus::Conductor::MultiError::UnlaunchableAssembly.new(I18n.t('deployments.flash.error.not_launched'),
errors)
end
rescue
- errs[assembly.name] = $!.message
+ errs = $!.message
end
end
errs
diff --git a/src/app/models/instance.rb b/src/app/models/instance.rb
index 65831a5..3a303f6 100644
--- a/src/app/models/instance.rb
+++ b/src/app/models/instance.rb
@@ -382,7 +382,6 @@ class Instance < ActiveRecord::Base
matched = []
pool.pool_family.provider_accounts.each do |account|
account.instance_matches(self, matched, errors)
-
end
[matched, errors]
diff --git a/src/app/views/layouts/_new_notification.html.haml
b/src/app/views/layouts/_new_notification.html.haml
index 99b3230..54ed324 100644
--- a/src/app/views/layouts/_new_notification.html.haml
+++ b/src/app/views/layouts/_new_notification.html.haml
@@ -44,7 +44,7 @@
=image_tag 'flash_notice_icon.png', :alt => 'Notices'
%ul.flashes
- flash[:error][:successes].each do |k, v|
- %li= "#{k}: #{v}"
+ %li= [k, v.present? ? ": #{v}" : '']
.error.flash-group
-if !flash[:error][:summary].blank?
.flash-subset
@@ -59,7 +59,7 @@
-if !flash[:error][:failures].blank?
-if flash[:error][:failures].length > 1
-flash[:error][:failures].each do |k, v|
- %li= [k, ': ', v]
+ %li= [k, v.present? ? ": #{v}" : '']
-else
-flash[:error][:failures].each do |k, v|
%li= [v]
diff --git a/src/lib/exceptions.rb b/src/lib/exceptions.rb
index 0a0bd3a..d56ddb3 100644
--- a/src/lib/exceptions.rb
+++ b/src/lib/exceptions.rb
@@ -48,5 +48,21 @@ module Aeolus
class ImageNotFound < StandardError; end
class BlankImageId < StandardError; end
end
+
+ module MultiError
+ class Error < StandardError
+ attr_reader :preamble
+ attr_reader :message
+ def initialize(preamble="", message=[])
+ @preamble = preamble
+ @message = message
+ end
+ def message
+ ([@preamble] + @message).flatten
+ end
+ end
+ class UnlaunchableAssembly < Error; end
+ end
+
end
end
--
1.7.6.5