<bdo id='4NxKk'></bdo><ul id='4NxKk'></ul>

<small id='4NxKk'></small><noframes id='4NxKk'>

    <i id='4NxKk'><tr id='4NxKk'><dt id='4NxKk'><q id='4NxKk'><span id='4NxKk'><b id='4NxKk'><form id='4NxKk'><ins id='4NxKk'></ins><ul id='4NxKk'></ul><sub id='4NxKk'></sub></form><legend id='4NxKk'></legend><bdo id='4NxKk'><pre id='4NxKk'><center id='4NxKk'></center></pre></bdo></b><th id='4NxKk'></th></span></q></dt></tr></i><div id='4NxKk'><tfoot id='4NxKk'></tfoot><dl id='4NxKk'><fieldset id='4NxKk'></fieldset></dl></div>

        <tfoot id='4NxKk'></tfoot>

      1. <legend id='4NxKk'><style id='4NxKk'><dir id='4NxKk'><q id='4NxKk'></q></dir></style></legend>
      2. yii2:抛出新异常的正确方法

        时间:2023-10-15

        <small id='UjIpk'></small><noframes id='UjIpk'>

        • <legend id='UjIpk'><style id='UjIpk'><dir id='UjIpk'><q id='UjIpk'></q></dir></style></legend>
            <bdo id='UjIpk'></bdo><ul id='UjIpk'></ul>
                <tbody id='UjIpk'></tbody>
              <tfoot id='UjIpk'></tfoot>
              1. <i id='UjIpk'><tr id='UjIpk'><dt id='UjIpk'><q id='UjIpk'><span id='UjIpk'><b id='UjIpk'><form id='UjIpk'><ins id='UjIpk'></ins><ul id='UjIpk'></ul><sub id='UjIpk'></sub></form><legend id='UjIpk'></legend><bdo id='UjIpk'><pre id='UjIpk'><center id='UjIpk'></center></pre></bdo></b><th id='UjIpk'></th></span></q></dt></tr></i><div id='UjIpk'><tfoot id='UjIpk'></tfoot><dl id='UjIpk'><fieldset id='UjIpk'></fieldset></dl></div>

                  本文介绍了yii2:抛出新异常的正确方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  只是为了测试,我在我的模型中添加了这段代码,同时设置了 debug = true 和 false.

                  Just for testing I have added this code in my model while setting the debug = true and false.

                  if($packagedays < 1)
                       {
                        throw new yiiaseException( "package days cannot be less than 1" );
                       }
                  

                  现在当 Yii 调试为真时:我得到了

                  Now when Yii debug is true: I am getting

                  异常 – yiiaseException包裹天数不能少于 1

                  但是当我将调试设置为 false 时我正进入(状态例外发生内部服务器错误.

                  But when I am setting the debug to false I am getting Exception An internal server error occurred.

                  上述错误发生在 Web 服务器处理您的请求时.

                  The above error occurred while the Web server was processing your request.

                  我想要的是替换发生内部服务器错误.包天数不能小于1debug=false

                  我在这里缺少什么?

                  谢谢.

                  推荐答案

                  你应该简单地抛出一个 UserException :

                  You should simply throw a UserException :

                  UserException 是旨在向最终用户显示的异常的基类.

                  UserException is the base class for exceptions that are meant to be shown to end users.

                  阅读更多:http://www.yiiframework.com/doc-2.0/yii-base-userexception.html

                  这篇关于yii2:抛出新异常的正确方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Yii2:使用 kartik 日期范围选择器在 gridview 中进行过滤 下一篇:在 PHP 中显示 Active Directory 中的缩略图

                  相关文章

                    <bdo id='aha3H'></bdo><ul id='aha3H'></ul>

                    <tfoot id='aha3H'></tfoot>

                      <legend id='aha3H'><style id='aha3H'><dir id='aha3H'><q id='aha3H'></q></dir></style></legend>
                    1. <i id='aha3H'><tr id='aha3H'><dt id='aha3H'><q id='aha3H'><span id='aha3H'><b id='aha3H'><form id='aha3H'><ins id='aha3H'></ins><ul id='aha3H'></ul><sub id='aha3H'></sub></form><legend id='aha3H'></legend><bdo id='aha3H'><pre id='aha3H'><center id='aha3H'></center></pre></bdo></b><th id='aha3H'></th></span></q></dt></tr></i><div id='aha3H'><tfoot id='aha3H'></tfoot><dl id='aha3H'><fieldset id='aha3H'></fieldset></dl></div>

                      <small id='aha3H'></small><noframes id='aha3H'>