framework icon indicating copy to clipboard operation
framework copied to clipboard

use Conditionable on Exceptions

Open hosseinakbari8013 opened this issue 1 year ago • 2 comments

This PR gives capabilities to the Exceptions class so that users can write their codes with better quality. In this PR, Illuminate\Support\Traits\Conditionable is used in the Illuminate\Foundation\Configuration\Exception class, so the exception will accept the when() and unless() functions. You can see a difference in the use of this function:

With out using when() (Execution of n conditions for n exceptions) image

With using when() (Execution of 1 conditions for n exceptions) image

note: I had no idea to make a new test for these changes, so I ask you to check it out, Thank's.

hosseinakbari8013 avatar Sep 26 '24 11:09 hosseinakbari8013

How would request be injected into your when callback?

taylorotwell avatar Sep 27 '24 14:09 taylorotwell

Wouldn't it make more sense to add a withExceptions() method to \Illuminate\Routing\Router?

shaedrich avatar Sep 28 '24 18:09 shaedrich