How can I avoid http error page when throw it exception on Laravel 5
Closed this issue · 3 comments
ALTELMA commented
ChrisRM commented
As I said in my first response, you need to catch the error and respond accordingly. E.g:
try {
$result = $mc->request('lists', [
'fields' => 'lists.id,lists.name,lists.stats.member_count',
'offset' => 10,
'count' => 10
]);
return response()->json([
'code' => 200,
'result' => $result
]);
} catch(Exception $e) {
return response()->json([
'code' => $e->getCode(),
'result' => $e->getMessage()
]);
}
cschalenborgh commented
Laravel 5 is namespaced, so you need to use "\Exception" instead of "Exception"
ALTELMA commented
I think not like that. I am newbie for Laravel 5 and I just know when throw http 404 or 501 will display error page instead. I need to know how can I send an error pass this page.
Sorry for my language. My Question not clear, right?