鍍金池/ 問答/PHP/ Laravel中的Exception與Throwable各自負(fù)責(zé)什么樣的任務(wù)

        Laravel中的Exception與Throwable各自負(fù)責(zé)什么樣的任務(wù)

        下面的是框架的源碼
        圖片描述

        我想知道源代碼中為什么多了一個(gè)Throwable?平時(shí)寫代碼都是用Exception的。還請(qǐng)各路大神指教!

        回答
        編輯回答
        巫婆

        Throwable 是 php7 新增的頂級(jí)異常 interface,包含了 Error 和 Exception。

        Throwable is the base interface for any object that can be thrown via
        a throw statement in PHP 7, including Error and Exception.

        PHP classes cannot implement the Throwable interface directly, and
        must instead extend Exception.

        2017年1月14日 17:25
        編輯回答
        笨笨噠
        Throwable = Exception + Error
        2017年2月2日 22:23