-
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.
add:configuration Discord notifier and test route in web.php
- Loading branch information
1 parent
a0c37e0
commit ac505bf
Showing
4 changed files
with
59 additions
and
31 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace App\Http\Middleware; | ||
|
||
use Closure; | ||
use Throwable; | ||
use App\Helpers\DiscordNotifier; | ||
|
||
class HandleExceptions | ||
{ | ||
public function handle($request, Closure $next) | ||
{ | ||
try { | ||
return $next($request); | ||
} catch (Throwable $e) { | ||
$this->reportToDiscord($e); // Enviar notificación a Discord | ||
throw $e; // Rethrow para permitir que el sistema maneje la excepción | ||
} | ||
} | ||
|
||
protected function reportToDiscord(Throwable $exception) | ||
{ | ||
$message = "**🚨 Excepción Crítica**\n" | ||
. "**Mensaje:** {$exception->getMessage()}\n" | ||
. "**Archivo:** {$exception->getFile()}:{$exception->getLine()}\n" | ||
. "**Trace:** ```" . substr($exception->getTraceAsString(), 0, 1800) . "```"; | ||
|
||
DiscordNotifier::send($message); | ||
} | ||
} |
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