pacely/mailchimp-api-v3

How can I avoid http error page when throw it exception on Laravel 5

Closed this issue · 3 comments

I mean like this. And How can I avoid from error page, I send response as json.

Image of example

Sorry, for repost this issue.

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()
    ]);
}

Laravel 5 is namespaced, so you need to use "\Exception" instead of "Exception"

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?