def self.convert(obj, default_name="error")
case obj
when nil then nil
when Condition then obj
when Exception then Condition.new(obj.class.name, obj.to_s)
when SWIG::TYPE_p_pn_condition_t
if Cproton.pn_condition_is_set(obj)
Condition.new(Cproton.pn_condition_get_name(obj),
Cproton.pn_condition_get_description(obj),
Codec::Data.to_object(Cproton.pn_condition_info(obj)))
end
else
raise ::ArgumentError, "can't convert #{obj.class.name} to #{self.class.name}" unless obj.respond_to? :to_str
Condition.new(default_name, obj.to_str)
end
end