Commit add4f4a
[12.x] Improve BroadcastManager error messages when trying to get a Broadcaster (#57275)
* [12.x] Improve BroadcastManager error messages when trying to get a Broadcaster
Previously, when a broadcaster driver failed to initialize, the error message would only show the underlying exception without indicating which broadcasting connection configuration was responsible, and it was hard to identify it was actually coming from a broadcaster.
Missing to provide a value for REVERB_APP_KEY, REVERB_APP_ID or REVERB_APP_SECRET would throw an error such as `TypeError: Pusher\Pusher::__construct(): Argument #3 ($app_id) must be of type string, null given` and it would occur after running `composer install`, `php artisan optimize` or any command that would cause the broadcasting to be booted.
This change wraps driver creation in a try-catch block that throws a BroadcastException with the connection name, making it immediately clear where the error is coming from and which configuration needs to be fixed.
Before:
> TypeError: Pusher\Pusher::__construct(): Argument #3 ($app_id) must be of type string, null given
After:
> BroadcastException: Failed to create broadcaster for connection "terminal" with error: Pusher\Pusher::__construct(): Argument #3 ($app_id) must be of type string, null given
* [12.x] Improve BroadcastManager error messages when trying to get a Broadcaster
Previously, when a broadcaster driver failed to initialize, the error message would only show the underlying exception without indicating which broadcasting connection configuration was responsible, and it was hard to identify it was actually coming from a broadcaster.
Missing to provide a value for REVERB_APP_KEY, REVERB_APP_ID or REVERB_APP_SECRET would throw an error such as `TypeError: Pusher\Pusher::__construct(): Argument #3 ($app_id) must be of type string, null given` and it would occur after running `composer install`, `php artisan optimize` or any command that would cause the broadcasting to be booted.
This change wraps driver creation in a try-catch block that throws a BroadcastException with the connection name, making it immediately clear where the error is coming from and which configuration needs to be fixed.
Before:
> TypeError: Pusher\Pusher::__construct(): Argument #3 ($app_id) must be of type string, null given
After:
> BroadcastException: Failed to create broadcaster for connection "my-connection" with error: Pusher\Pusher::__construct(): Argument #3 ($app_id) must be of type string, null given
* [12.x] Improve BroadcastManager error messages when trying to get a Broadcaster
Previously, when a broadcaster driver failed to initialize, the error message would only show the underlying exception without indicating which broadcasting connection configuration was responsible, and it was hard to identify it was actually coming from a broadcaster.
Missing to provide a value for REVERB_APP_KEY, REVERB_APP_ID or REVERB_APP_SECRET would throw an error such as `TypeError: Pusher\Pusher::__construct(): Argument #3 ($app_id) must be of type string, null given` and it would occur after running `composer install`, `php artisan optimize` or any command that would cause the broadcasting to be booted.
This change wraps driver creation in a try-catch block that throws a BroadcastException with the connection name, making it immediately clear where the error is coming from and which configuration needs to be fixed.
Before:
> TypeError: Pusher\Pusher::__construct(): Argument #3 ($app_id) must be of type string, null given
After:
> BroadcastException: Failed to create broadcaster for connection "my-connection" with error: Pusher\Pusher::__construct(): Argument #3 ($app_id) must be of type string, null given
* [12.x] Improve BroadcastManager error messages when trying to get a Broadcaster
Previously, when a broadcaster driver failed to initialize, the error message would only show the underlying exception without indicating which broadcasting connection configuration was responsible, and it was hard to identify it was actually coming from a broadcaster.
Missing to provide a value for REVERB_APP_KEY, REVERB_APP_ID or REVERB_APP_SECRET would throw an error such as `TypeError: Pusher\Pusher::__construct(): Argument #3 ($app_id) must be of type string, null given` and it would occur after running `composer install`, `php artisan optimize` or any command that would cause the broadcasting to be booted.
This change wraps driver creation in a try-catch block that throws a BroadcastException with the connection name, making it immediately clear where the error is coming from and which configuration needs to be fixed.
Before:
> TypeError: Pusher\Pusher::__construct(): Argument #3 ($app_id) must be of type string, null given
After:
> BroadcastException: Failed to create broadcaster for connection "my-connection" with error: Pusher\Pusher::__construct(): Argument #3 ($app_id) must be of type string, null given
* [12.x] Improve BroadcastManager error messages when trying to get a Broadcaster
Previously, when a broadcaster driver failed to initialize, the error message would only show the underlying exception without indicating which broadcasting connection configuration was responsible, and it was hard to identify it was actually coming from a broadcaster.
Missing to provide a value for REVERB_APP_KEY, REVERB_APP_ID or REVERB_APP_SECRET would throw an error such as `TypeError: Pusher\Pusher::__construct(): Argument #3 ($app_id) must be of type string, null given` and it would occur after running `composer install`, `php artisan optimize` or any command that would cause the broadcasting to be booted.
This change wraps driver creation in a try-catch block that throws a BroadcastException with the connection name, making it immediately clear where the error is coming from and which configuration needs to be fixed.
Before:
> TypeError: Pusher\Pusher::__construct(): Argument #3 ($app_id) must be of type string, null given
After:
> BroadcastException: Failed to create broadcaster for connection "my-connection" with error: Pusher\Pusher::__construct(): Argument #3 ($app_id) must be of type string, null given
Testing using the LogBroadcaster since it is always available, while Pusher\Pusher is not.
* formatting
---------
Co-authored-by: Taylor Otwell <[email protected]>1 parent 92ea383 commit add4f4a
File tree
2 files changed
+38
-1
lines changed- src/Illuminate/Broadcasting
- tests/Integration/Broadcasting
2 files changed
+38
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| |||
292 | 294 | | |
293 | 295 | | |
294 | 296 | | |
295 | | - | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
296 | 302 | | |
297 | 303 | | |
298 | 304 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| 21 | + | |
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
| |||
100 | 102 | | |
101 | 103 | | |
102 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
103 | 134 | | |
104 | 135 | | |
105 | 136 | | |
| |||
0 commit comments