From: Martyn Taylor <mtaylor(a)redhat.com>
---
src/app/controllers/application_controller.rb | 5 +++++
src/app/views/api/error.xml.haml | 2 ++
src/config/application.rb | 2 ++
3 files changed, 9 insertions(+), 0 deletions(-)
create mode 100644 src/app/views/api/error.xml.haml
diff --git a/src/app/controllers/application_controller.rb
b/src/app/controllers/application_controller.rb
index 3f365af..9d51b3d 100644
--- a/src/app/controllers/application_controller.rb
+++ b/src/app/controllers/application_controller.rb
@@ -34,6 +34,7 @@ class ApplicationController < ActionController::Base
rescue_from ActionError, :with => :handle_action_error
rescue_from PartialSuccessError, :with => :handle_partial_success_error
rescue_from ActiveRecord::RecordNotFound, :with =>
:handle_active_record_not_found_error
+ rescue_from Aeolus::Conductor::API::Error, :with => :handle_api_error
helper_method :check_privilege
@@ -107,6 +108,10 @@ class ApplicationController < ActionController::Base
flash[:notice] = t('application_controller.flash.notice.record_not_exist')
end
+ def handle_api_error(error)
+ render :template => 'api/error', :locals => {:error => error},
:status => error.status
+ end
+
# Returns an array of ids from params[:id], params[:ids].
def ids_list(other_attrs=[])
other_attrs.each do |attr_key|
diff --git a/src/app/views/api/error.xml.haml b/src/app/views/api/error.xml.haml
new file mode 100644
index 0000000..a8bc38b
--- /dev/null
+++ b/src/app/views/api/error.xml.haml
@@ -0,0 +1,2 @@
+!!!XML
+%error=error.class.name.demodulize
\ No newline at end of file
diff --git a/src/config/application.rb b/src/config/application.rb
index 154ebdb..f19c6f5 100644
--- a/src/config/application.rb
+++ b/src/config/application.rb
@@ -92,6 +92,8 @@ module Conductor
# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"
+ require File.dirname(__FILE__) + '/../lib/exceptions'
+
# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password, :password_confirmation]
require File.dirname(__FILE__) + '/../lib/warehouse_model'
--
1.7.6.4
Show replies by date