2011-09-22 38 views
-1

當你開始捕捉異常,異常自動加載機控制器錯誤彈出:例外 - 比如錯誤

Argument 1 passed to Controller_Exception:: __construct() must be an instance of Autoloader_Exception, string given, Called in 'source' 


try {} catch (Autoloader_Exception $ e){ throw new Controller_Exception ('Some Error'); }} 

Controller_Exception class { public function __construct ($ Autoloader_Exception e) { } } 

問題二,如何建立一個異常類?有人知道一個很好的例子嗎?

+0

你使用什麼語言?你能提供一些背景嗎? –

+1

什麼是*第一個*問題? – Peter

回答

0

第一個問題是,你正在使用

new Controller_Exception ('Some Error') 

根據錯誤信息「一些錯誤」必須是一個Autoloader_Exception。根據你想做什麼,你可以使用:

new Controller_Exception ($e) 

因爲你可以閱讀有關創建自己的異常here第二個問題。