rails 4:404,500的自定义错误页面以及默认的500错误消息来自哪里? [英] rails 4: custom error pages for 404, 500 and where is the default 500 error message coming from?
问题描述
目前正在生产中获取此文本:
Currently in production im getting this text:
500 Internal Server Error
If you are the administrator of this website, then please read this web application's
log file and/or the web server's log file to find out what went wrong.
该页面中没有html没有。
No html in that page nothing.
这个代码位于哪里?我有否 public / 500.html或任何这方面。
Where is this code situated? I have no public/500.html or anything in that regard.
在我的路线我有:
get "/404", :to => "errors#error_404"
get "/422", :to => "errors#error_404"
get "/500", :to => "errors#error_500"
get "/505", :to => "errors#error_505"
错误控制器:
class ErrorsController < ApplicationController
def sub_layout
"left"
end
def error_404
render :status => 404, :formats => [:html], :layout => "white", :sub_layout => "left"
end
def error_422
render :status => 422, :formats => [:html], :layout => "white", :sub_layout => "left"
end
def error_500
render :status => 500, :formats => [:html], :layout => "white", :sub_layout => "left"
end
def error_505
render :status => 505, :formats => [:html], :layout => "white", :sub_layout => "left"
end
end
如何使它总是加载我的自定义错误?在一些错误,它只是抛出2行文本来自rails core的某个地方,我希望它每次都能获取自定义风格的错误页面!怎么样? thx!
How to make it load my custom errors always? On some errors it just throw that 2 line text coming somewhere from rails core, I want it to pickup my custom styled error pages every time! how? thx!
推荐答案
您正在遇到的错误是从
这意味着你的异常被救出的代码本身就是抛出异常。
您可以检查您的日志文本:
This means, the code your exceptions are getting rescued by are themselves throwing exceptions. You can check your logs for text:
故障安全响应时出错:
来确定真正的异常来源,从而解决您的问题。
to identify what the exceptions really are originating from and thus solve your problem.
这篇关于rails 4:404,500的自定义错误页面以及默认的500错误消息来自哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!