forked from laravel/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[9.x] Return non-zero exit code for uncaught exceptions (laravel#46541)
* wip * Update MakesArtisanScript.php * artisanScript function * Update MakesArtisanScript.php * styleci * change to PhpExecutableFinder * move `exit(1)` call up to only console applications * styleci * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * imports * formatting --------- Signed-off-by: Mior Muhammad Zaki <[email protected]> Co-authored-by: Mior Muhammad Zaki <[email protected]> Co-authored-by: Taylor Otwell <[email protected]>
- Loading branch information
1 parent
4307b85
commit 6114330
Showing
6 changed files
with
126 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
tests/Integration/Foundation/Fixtures/Console/ThrowExceptionCommand.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace Illuminate\Tests\Integration\Foundation\Fixtures\Console; | ||
|
||
use Exception; | ||
use Illuminate\Console\Command; | ||
|
||
class ThrowExceptionCommand extends Command | ||
{ | ||
protected $signature = 'throw-exception-command'; | ||
|
||
public function handle() | ||
{ | ||
throw new Exception('Thrown inside ThrowExceptionCommand'); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
tests/Integration/Foundation/Fixtures/Logs/ThrowExceptionLogHandler.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace Illuminate\Tests\Integration\Foundation\Fixtures\Logs; | ||
|
||
use Exception; | ||
use Monolog\Handler\AbstractProcessingHandler; | ||
|
||
class ThrowExceptionLogHandler extends AbstractProcessingHandler | ||
{ | ||
protected function write(array $record): void | ||
{ | ||
throw new Exception('Thrown inside ThrowExceptionLogHandler'); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
tests/Integration/Foundation/Fixtures/Providers/ThrowExceptionServiceProvider.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace Illuminate\Tests\Integration\Foundation\Fixtures\Providers; | ||
|
||
use Illuminate\Console\Application; | ||
use Illuminate\Support\ServiceProvider; | ||
use Illuminate\Tests\Integration\Foundation\Fixtures\Console\ThrowExceptionCommand; | ||
|
||
class ThrowExceptionServiceProvider extends ServiceProvider | ||
{ | ||
public function boot() | ||
{ | ||
Application::starting(function ($artisan) { | ||
$artisan->add(new ThrowExceptionCommand); | ||
}); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
tests/Integration/Foundation/Fixtures/Providers/ThrowUncaughtExceptionServiceProvider.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace Illuminate\Tests\Integration\Foundation\Fixtures\Providers; | ||
|
||
use Illuminate\Console\Application; | ||
use Illuminate\Support\ServiceProvider; | ||
use Illuminate\Tests\Integration\Foundation\Fixtures\Console\ThrowExceptionCommand; | ||
use Illuminate\Tests\Integration\Foundation\Fixtures\Logs\ThrowExceptionLogHandler; | ||
|
||
class ThrowUncaughtExceptionServiceProvider extends ServiceProvider | ||
{ | ||
public function register() | ||
{ | ||
$config = $this->app['config']; | ||
|
||
$config->set('logging.default', 'throw_exception'); | ||
|
||
$config->set('logging.channels.throw_exception', [ | ||
'driver' => 'monolog', | ||
'handler' => ThrowExceptionLogHandler::class, | ||
]); | ||
} | ||
|
||
public function boot() | ||
{ | ||
Application::starting(function ($artisan) { | ||
$artisan->add(new ThrowExceptionCommand); | ||
}); | ||
} | ||
} |