鍍金池/ 問答/PHP/ Laravel中的Exception與Throwable各自負責什么樣的任務

Laravel中的Exception與Throwable各自負責什么樣的任務

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

我想知道源代碼中為什么多了一個Throwable?平時寫代碼都是用Exception的。還請各路大神指教!

回答
編輯回答
巫婆

Throwable 是 php7 新增的頂級異常 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