Allow the client to request errors as an XML document
This commit is contained in:
parent
3472c1d429
commit
f20a85a5c5
3 changed files with 42 additions and 1 deletions
|
@ -162,7 +162,18 @@ class ApplicationController < ActionController::Base
|
|||
def report_error(message, status = :bad_request)
|
||||
# Todo: some sort of escaping of problem characters in the message
|
||||
response.headers['Error'] = message
|
||||
render :text => message, :status => status
|
||||
|
||||
if request.headers['X-Error-Format'] and
|
||||
request.headers['X-Error-Format'].downcase == "xml"
|
||||
result = OSM::API.new.get_xml_doc
|
||||
result.root.name = "osmError"
|
||||
result.root << (XML::Node.new("status") << interpret_status(status))
|
||||
result.root << (XML::Node.new("message") << message)
|
||||
|
||||
render :text => result.to_s, :content_type => "text/xml"
|
||||
else
|
||||
render :text => message, :status => status
|
||||
end
|
||||
end
|
||||
|
||||
def set_locale
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue