2016-09-26 47 views
1

我有一些自定義路線返回JSON與octoberCMS例外

Route::get('/files/', [ 
      'as' => 'read', 
      'uses' => 'Myname\MyPlugin\Http\Controllers\[email protected]' 
     ]); 

某處在我的課我有一個函數來驗證路徑

private function getPath() 
{ 
    $path = Input::get('path'); 

    if (!$path) 
    { 
    throw new MyException('parameter is missing. path required', 400); 
    } 

    return base_path().'/'.$path; 
} 

我已經設置了自定義錯誤處理程序與JSOM但它是OctoberCMS的錯誤處理程序,它以HTML格式呈現錯誤。

你知道一種方法來替換10CMS的默認錯誤處理程序的自定義嗎? 感謝

回答

0

剛剛找到的文檔中的anwser:https://octobercms.com/docs/services/error-log#exception-handling

月提供應用程序:錯誤在你的插件來管理異常。

App::error(function(MyException $exception) { 
//do what you want here 
} 

不要爲您的插件創建自定義異常。如果您使用通用例外,您將捕獲所有例外。