doutan8506 2018-08-16 06:15
浏览 125

当我尝试使用set_error_handler时,Laravel会出现unserialize()错误

in Laravel i'm trying to use php set_error_handler method to handel errors by web application and avoid to crash that, unfortunately when i define this code on __constructor() such as this sample i get this error:

array:4 [▼
"Error no " => 8
"Error String" => "unserialize(): Error at offset 0 of 123 bytes"
"Error File " => "C:\xampp\htdocs\instacheeta\vendor\laravel\framework\src\Illuminate\Auth\Recaller.php" "Error Line" => 24 ]

my code:

public function __construct()
{
    set_error_handler([$this, 'customError'], E_ALL);
    parent::__construct();
}

function customError($errno, $errstr, $errfile, $errline)
{
    dd(
        [
            'Error no ' => $errno,
            'Error String' => $errstr,
            'Error File ' => $errfile,
            'Error Line' => $errline
        ]
    );
}

it seems problem is using arguments on dd, when i commented dd i dont get error

how can i resolve this problem?

  • 写回答

1条回答 默认 最新

  • dongying6659 2018-08-16 07:00
    关注

    There's nothing wrong with what you did. Unfortunately you have set your own error-handler which calls the customError method. obviously i think there really is an error.

    DD dumps the given variables and ends execution of the script as stated in the documentation.

    so when you deleted the DD line the method customError became empty/void although the captured error is still there.

    That is the purpose of using set_error_handler so you could set a user-defined error handler function and decide what to do with the trapped errors.

    评论

报告相同问题?

悬赏问题

  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路