File tree Expand file tree Collapse file tree 4 files changed +51
-0
lines changed Expand file tree Collapse file tree 4 files changed +51
-0
lines changed Original file line number Diff line number Diff line change 2323 'auth ' => [
2424 'bearer ' => 'testing ' ,
2525 ],
26+
27+ 'interacts_telescope ' => env ('INTERACTS_TELESCOPE ' ),
2628];
Original file line number Diff line number Diff line change 44
55use Binarcode \LaravelDeveloper \Dtos \DevNotificationDto ;
66use Binarcode \LaravelDeveloper \Models \ExceptionLog ;
7+ use Binarcode \LaravelDeveloper \Telescope \TelescopeException ;
78use Illuminate \Support \Collection ;
89use Illuminate \Support \Facades \Notification as NotificationFacade ;
910use Throwable ;
@@ -57,6 +58,10 @@ private function send($item)
5758 $ dto = DevNotificationDto::makeFromExceptionLog (
5859 tap (ExceptionLog::makeFromException ($ item ), fn (ExceptionLog $ log ) => $ log ->save ())
5960 );
61+
62+ if (config ('developer.interacts_telescope ' )) {
63+ TelescopeException::recordException ($ item );
64+ }
6065 } else {
6166 $ dto = DevNotificationDto::makeFromException ($ item );
6267 }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Binarcode \LaravelDeveloper \Telescope ;
4+
5+ use Throwable ;
6+
7+ class TelescopeException
8+ {
9+ public static function recordException (Throwable $ exception , $ message = null ): void
10+ {
11+ if (!class_exists ('Laravel \\Telescope \\Telescope ' ) ||
12+ !class_exists ('Laravel \\Telescope \\IncomingExceptionEntry ' ) ||
13+ !class_exists ('Laravel \\Telescope \\ExceptionContext ' )
14+ ) {
15+ return ;
16+ }
17+
18+ $ trace = collect ($ exception ->getTrace ())->map (function ($ item ) {
19+ return Arr::only ($ item , ['file ' , 'line ' ]);
20+ })->toArray ();
21+
22+ Telescope::recordException (
23+ IncomingExceptionEntry::make ($ exception , [
24+ 'class ' => get_class ($ exception ),
25+ 'file ' => $ exception ->getFile (),
26+ 'line ' => $ exception ->getLine (),
27+ 'message ' => $ message ?? $ exception ->getMessage (),
28+ 'context ' => null ,
29+ 'trace ' => $ trace ,
30+ 'line_preview ' => ExceptionContext::get ($ exception ),
31+ ])
32+ );
33+ }
34+ }
Original file line number Diff line number Diff line change 44use Binarcode \LaravelDeveloper \Notifications \Slack ;
55use Binarcode \LaravelDeveloper \Profiling \ServerMemory ;
66use Binarcode \LaravelDeveloper \Profiling \ServerTiming ;
7+ use Binarcode \LaravelDeveloper \Telescope \TelescopeException ;
78
89if (! function_exists ('measure_memory ' )) {
910 function measure_memory ($ callable = null , string $ key = 'action ' , string $ unit = 'mb ' )
@@ -54,3 +55,12 @@ function devLog(...$args): DevLog
5455 return DevLog::make (...$ args );
5556 }
5657}
58+
59+ if (! function_exists ('telescopeException ' )) {
60+ function telescopeException (Throwable $ exception , $ message = null ): void
61+ {
62+ if (config ('developer.interacts_telescope ' )) {
63+ TelescopeException::recordException ($ exception , $ message );
64+ }
65+ }
66+ }
You can’t perform that action at this time.
0 commit comments