poma

Throwing exceptions vs returning response

Posted 3 years ago by poma

I've recently tried to use FormRequest and found out that it returns 403 response instead of throwing HttpException when authorisation fails:

https://github.com/laravel/framework/blob/5.1/src/Illuminate/Foundation/Http/FormRequest.php#L147

Is it a bug or intended behaviour? I'm building a REST API and need unified JSON format for all errors. I've already customised my exception handler for that. But how am I supposed to track down all random pieces of code that decide to return a response by themselves?

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.