show error message when trying to show a not existed page
This commit is contained in:
parent
5d6279a9ea
commit
6da528ef98
|
@ -2,9 +2,13 @@ class ApplicationController < ActionController::Base
|
|||
protect_from_forgery
|
||||
|
||||
include ParserFrontEnd, ParserBackEnd, ApplicationHelper
|
||||
include OrbitApp::ErrorHandlers
|
||||
include OrbitApp::ErrorHandlers::PageErrorHandler
|
||||
include OrbitApp::ErrorHandlers::ObjectAuthErrorHandler
|
||||
include OrbitApp::ErrorHandlers::ModuleAppErrorHandler
|
||||
|
||||
rescue_from ObjectAuthError, :with => :render_object_auth_error
|
||||
rescue_from ModuleAppError, :with => :render_module_app_error
|
||||
rescue_from PageError, :with => :render_page_error
|
||||
|
||||
layout :layout_by_resource
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ class PagesController < ApplicationController
|
|||
end
|
||||
@item = Item.where(module_app_id: module_app.id,app_frontend_url:params[:app_action]).all_of("tag" => {"$in" => [nil,'']},"category" => { "$in" => [nil,'']}).first unless @item
|
||||
@item = Item.where(module_app_id: module_app.id,app_frontend_url:params[:app_action]).first unless @item
|
||||
#TODO 需要做 error handler 處理沒有新增該模組頁面導致錯誤的可能性
|
||||
raise PageError,'Missing Frontend Page'
|
||||
end
|
||||
|
||||
def save_from_no_lang_for_page
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
class PageError < StandardError
|
||||
|
||||
end
|
|
@ -0,0 +1,14 @@
|
|||
|
||||
# require "#{File.dirname(__FILE__)}/module_app_error_handler.rb"
|
||||
# require "#{File.dirname(__FILE__)}/object_auth_error_handler.rb"
|
||||
# require "#{File.dirname(__FILE__)}/module_app_error_handler.rb"
|
||||
# require "#{File.dirname(__FILE__)}/page_error_handler.rb"
|
||||
|
||||
|
||||
# module OrbitApp
|
||||
# module ErrorHandlers
|
||||
# module ApplicationsErrorHandler
|
||||
|
||||
# end
|
||||
# end
|
||||
# end
|
|
@ -0,0 +1,16 @@
|
|||
module OrbitApp
|
||||
module ErrorHandlers
|
||||
module PageErrorHandler
|
||||
|
||||
|
||||
def render_page_error(exception = nil)
|
||||
default_message = 'ModuleAppErrorHandler'
|
||||
meaasge = ''
|
||||
if exception
|
||||
meaasge = default_message + exception.message
|
||||
end
|
||||
render :text=>meaasge
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue