Skip to content

Commit

Permalink
feat: add exception-provider
Browse files Browse the repository at this point in the history
  • Loading branch information
jevantang committed Dec 8, 2022
1 parent 421165e commit cbe46f8
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
1 change: 1 addition & 0 deletions config/plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
'seeder' => 'database/seeders/DatabaseSeeder.php',
'route-provider' => 'app/Providers/RouteServiceProvider.php',
'command-provider' => 'app/Providers/CommandServiceProvider.php',
'exception-provider' => 'app/Providers/ExceptionServiceProvider.php',
'assets/js/app' => 'resources/assets/js/app.js',
'assets/sass/app' => 'resources/assets/sass/app.scss',
'webpack' => 'webpack.mix.js',
Expand Down
50 changes: 50 additions & 0 deletions src/Commands/stubs/exception-provider.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace $NAMESPACE$;

use App\Exceptions\Handler;
use Illuminate\Support\Str;
use Illuminate\Support\ServiceProvider;
use Illuminate\Console\Scheduling\Schedule;

class ExceptionServiceProvider extends ServiceProvider
{
/**
* Register any services.
*
* @return void
*/
public function boot()
{
$this->app->resolving(Handler::class, function ($handler) {
$handler->reportable([$this, 'reportable']);
$handler->renderable([$this, 'renderable']);
});
}

/**
* Register a reportable callback.
*
* @param callable $reportUsing
* @return \Illuminate\Foundation\Exceptions\ReportableHandler
*/
public function reportable()
{
return function (Throwable $e) {
//
};
}

/**
* Register a renderable callback.
*
* @param callable $renderUsing
* @return $this
*/
public function reportable()
{
return function (\Throwable $e) {
//
};
}
}
3 changes: 2 additions & 1 deletion src/Commands/stubs/plugin.json.stub
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"accessPath": "",
"settingPath": null,
"providers": [
"$PLUGIN_NAMESPACE$\\$STUDLY_NAME$\\Providers\\$STUDLY_NAME$ServiceProvider"
"$PLUGIN_NAMESPACE$\\$STUDLY_NAME$\\Providers\\$STUDLY_NAME$ServiceProvider",
"$PLUGIN_NAMESPACE$\\$STUDLY_NAME$\\Providers\\ExceptionServiceProvider"
],
"autoloadFiles": [],
"aliases": {}
Expand Down

0 comments on commit cbe46f8

Please sign in to comment.