Skip to content

Commit

Permalink
fix exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdanRada committed Dec 10, 2013
1 parent 823ca71 commit f6a3acf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Please read {release details}[https://github.com/bogdanRada/washout_builder/rele
The way soap_actions, or reusable types are defined or how the configuration is made using WashOut(https://github.com/inossidabile/wash_out) haven't changed
You can still do everything that gem does .

When specifying the <b>soap_action</b> you can also pass a <b>option for description</b> and a <b>list of exceptions(need to be instances as example)</b> that the method can raise at a certain moment.
When specifying the <b>soap_action</b> you can also pass a <b>option for description</b> and a <b>list of exceptions(need to be instances)</b> that the method can raise at a certain moment.

The exception classes used <b>must inherit</b> from <tt>WashOut::SOAPError</tt>, which has by default a error code and a message as attributes but you can extend it by adding more accessible_attributes to your own custom class.

Expand Down
27 changes: 15 additions & 12 deletions app/helpers/washout_builder_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ def fix_descendant_wash_out_type(param, complex_class)
if !param_class.nil? && param_class.ancestors.include?(WashOut::Type) && !param.map[0].nil?
descendant = WashOut::Param.parse_def(@soap_config, param_class.wash_out_param_map)[0]
param.name = descendant.name
param.map = descendant.map
param.map = descendant.map
end
end

def get_nested_complex_types(param, defined)
defined = [] if defined.blank?
complex_class = get_complex_class_name(param, defined)
fix_descendant_wash_out_type(param, complex_class)
fix_descendant_wash_out_type(param, complex_class)
defined << {:class =>complex_class, :obj => param, :ancestors => param.classified? ? get_class_ancestors(param, complex_class, defined) : nil } unless complex_class.nil?
if param.struct?
c_names = []
Expand All @@ -94,7 +94,8 @@ def get_complex_types(map)

def get_fault_types_names(map)
defined = map.select{|operation, formats| !formats[:raises].blank? }
defined.collect {|operation, formats| formats[:raises].is_a?(Array) ? formats[:raises] : [formats[:raises]] }.flatten.map{|item| item.class.to_s }.sort_by { |name| name.downcase }.uniq unless defined.blank?
defined = defined.collect {|operation, formats| formats[:raises].is_a?(Array) ? formats[:raises] : [formats[:raises]] }.flatten.select { |x| x.class.ancestors.include?(WashOut::SOAPError) } unless defined.blank?
defined.map{|item| item.class.to_s }.sort_by { |name| name.downcase }.uniq unless defined.blank?
end

def get_soap_action_names(map)
Expand Down Expand Up @@ -151,8 +152,7 @@ def create_html_fault_types_details(xml, map)
end

def create_html_fault_type(xml, param)
ancestor_class = defined?(WashOut::Dispatcher::SOAPError) ? WashOut::Dispatcher::SOAPError : WashOut::SOAPError
if param.class.ancestors.include?(ancestor_class)
if param.class.ancestors.include?(WashOut::SOAPError)
xml.h3 "#{param.class}"
xml.a("name" => "#{param.class}") {}
xml.ul("class" => "pre") {
Expand Down Expand Up @@ -287,13 +287,16 @@ def create_html_public_method(xml, operation, formats)
unless formats[:raises].blank?
faults = formats[:raises]
faults = [formats[:raises]] if !faults.is_a?(Array)
xml.p "Exceptions:"
xml.ul {
faults.each do |p|
xml.li("class" => "pre"){ |y| y<< "<a href='##{p.class.to_s}'><span class='lightBlue'> #{p.class.to_s}</span></a>" }
end
}
faults = faults.select { |x| x.class.ancestors.include?(WashOut::SOAPError) }
unless faults.blank?
xml.p "Exceptions:"
xml.ul {
faults.each do |p|
xml.li("class" => "pre"){ |y| y<< "<a href='##{p.class.to_s}'><span class='lightBlue'> #{p.class.to_s}</span></a>" }
end
}
end
end
end
Expand Down

0 comments on commit f6a3acf

Please sign in to comment.