From 17d4cac2080eb0c33d5daa5fc8174377b82bbc00 Mon Sep 17 00:00:00 2001 From: randx Date: Thu, 31 May 2012 23:36:52 +0300 Subject: [PATCH] Rescue encoding error on controller level --- app/controllers/application_controller.rb | 4 ++++ app/views/errors/encoding.html.haml | 6 ++++++ 2 files changed, 10 insertions(+) create mode 100644 app/views/errors/encoding.html.haml diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index a96c59b6..f311f8ae 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -9,6 +9,10 @@ class ApplicationController < ActionController::Base render "errors/gitolite", :layout => "error" end + rescue_from Encoding::CompatibilityError do |exception| + render "errors/encoding", :layout => "error", :status => 404 + end + rescue_from ActiveRecord::RecordNotFound do |exception| render "errors/not_found", :layout => "error", :status => 404 end diff --git a/app/views/errors/encoding.html.haml b/app/views/errors/encoding.html.haml new file mode 100644 index 00000000..c5cd2dd5 --- /dev/null +++ b/app/views/errors/encoding.html.haml @@ -0,0 +1,6 @@ +.alert-message.block-message.error + %h3 Encoding Error + %hr + %p + Page cant be loaded cause of encoding error +