1515
1616use Guanguans \LaravelExceptionNotify \Contracts \ChannelContract ;
1717use Guanguans \LaravelExceptionNotify \Events \ReportedEvent ;
18- use Guanguans \LaravelExceptionNotify \Events \ReportFailedEvent ;
1918use Guanguans \LaravelExceptionNotify \Events \ReportingEvent ;
2019use Guanguans \LaravelExceptionNotify \Support \Traits \AggregationTrait ;
2120use Illuminate \Cache \RateLimiter ;
2221use Illuminate \Support \Facades \Cache ;
2322use Illuminate \Support \Facades \Event ;
24- use function Guanguans \LaravelExceptionNotify \Support \rescue ;
2523
2624/**
2725 * @see \Illuminate\Log\Logger
@@ -45,33 +43,20 @@ public function reportIf(mixed $condition, \Throwable $throwable): void
4543
4644 public function report (\Throwable $ throwable ): void
4745 {
48- rescue (function () use ($ throwable ): void {
49- if ($ this ->shouldntReport ($ throwable )) {
50- return ;
51- }
46+ if ($ this ->shouldntReport ($ throwable )) {
47+ return ;
48+ }
5249
53- $ this ->channelContract ->report ($ throwable );
54- });
50+ $ this ->channelContract ->report ($ throwable );
5551 }
5652
5753 public function reportContent (string $ content ): mixed
5854 {
59- return rescue (
60- function () use ($ content ): mixed {
61- Event::dispatch (new ReportingEvent ($ this ->channelContract , $ content ));
62-
63- $ result = $ this ->channelContract ->reportContent ($ content );
55+ Event::dispatch (new ReportingEvent ($ this ->channelContract , $ content ));
56+ $ result = $ this ->channelContract ->reportContent ($ content );
57+ Event::dispatch (new ReportedEvent ($ this ->channelContract , $ result ));
6458
65- Event::dispatch (new ReportedEvent ($ this ->channelContract , $ result ));
66-
67- return $ result ;
68- },
69- function (\Throwable $ throwable ): \Throwable {
70- Event::dispatch (new ReportFailedEvent ($ this ->channelContract , $ throwable ));
71-
72- return $ throwable ;
73- }
74- );
59+ return $ result ;
7560 }
7661
7762 public function reporting (mixed $ listener ): void
@@ -84,11 +69,6 @@ public function reported(mixed $listener): void
8469 Event::listen (ReportedEvent::class, $ listener );
8570 }
8671
87- public function reportFailed (mixed $ listener ): void
88- {
89- Event::listen (ReportFailedEvent::class, $ listener );
90- }
91-
9272 public static function skipWhen (\Closure $ callback ): void
9373 {
9474 self ::$ skipCallbacks [] = $ callback ;
@@ -100,6 +80,8 @@ public function shouldReport(\Throwable $throwable): bool
10080 }
10181
10282 /**
83+ * @see \Illuminate\Foundation\Exceptions\Handler::shouldntReport()
84+ *
10385 * @noinspection NotOptimalIfConditionsInspection
10486 */
10587 private function shouldntReport (\Throwable $ throwable ): bool
@@ -130,13 +112,15 @@ private function shouldSkip(\Throwable $throwable): bool
130112 return false ;
131113 }
132114
115+ /**
116+ * @see \Illuminate\Foundation\Exceptions\Handler::shouldntReport()
117+ */
133118 private function fingerprintFor (\Throwable $ throwable ): string
134119 {
135120 return config ('exception-notify.rate_limit.key_prefix ' ).sha1 (implode ('| ' , [
136121 $ throwable ->getFile (),
137122 $ throwable ->getLine (),
138123 $ throwable ->getCode (),
139- // $throwable->getTraceAsString(),
140124 ]));
141125 }
142126
0 commit comments