douao1854 2014-02-20 15:19
浏览 87
已采纳

从set_exception_handler函数中获取异常名称

I have a couple of exception ex:

fooException extends Exception{}
barException extends Exception{}
tarException extends Exception{}

here is the exception handler

 set_exception_handler('get_exceptions');

  function get_exceptions($msg){
    # how to get the exception name here like
    # fooException barException
  }

example errors

 if(0){
    throw new fooException;  
 }

 if(!1){
   throw new barException;  
 }

Now, inside the get_exceptions function I am trying but unable to get what exception type that is being thrown, instead of the the message, code and the whole data. just the name of the class, like fooException or barException is there anyway to get only the name of the triggered exception ?

  • 写回答

1条回答 默认 最新

  • dongre8505 2014-02-20 15:41
    关注

    try

    $exceptionClass = get_class($msg);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置