]> git.openstreetmap.org Git - rails.git/blob - app/controllers/old_relation_controller.rb
Remove a rescue, which is stopping a more detailed error message being returned to...
[rails.git] / app / controllers / old_relation_controller.rb
1 class OldRelationController < ApplicationController
2   require 'xml/libxml'
3
4   session :off
5   before_filter :check_api_readable
6   after_filter :compress_output
7
8   def history
9     begin
10       relation = Relation.find(params[:id])
11       doc = OSM::API.new.get_xml_doc
12
13       relation.old_relations.each do |old_relation|
14         doc.root << old_relation.to_xml_node
15       end
16
17       render :text => doc.to_s, :content_type => "text/xml"
18     rescue ActiveRecord::RecordNotFound
19       render :nothing => true, :status => :not_found
20     rescue
21       render :nothing => true, :status => :internal_server_error
22     end
23   end
24   
25   def version
26     begin
27       old_relation = OldRelation.find(:first, :conditions => {:id => params[:id], :version => params[:version]} )
28       if old_relation.nil?
29         # (RecordNotFound is not raised with find :first...)
30         render :nothing => true, :status => :not_found
31         return
32       end
33       
34       response.headers['Last-Modified'] = old_relation.timestamp.rfc822
35
36       doc = OSM::API.new.get_xml_doc
37       doc.root << old_relation.to_xml_node
38
39       render :text => doc.to_s, :content_type => "text/xml"
40     rescue
41       render :nothing => true, :status => :internal_server_error
42     end
43   end
44 end