Skip to content

[Notifier] [DX] UnsupportedMessageTypeException for notifier transports #39365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 11, 2020

Conversation

OskarStark
Copy link
Contributor

Q A
Branch? 5.x
Bug fix? no
New feature? yes
Deprecations? no
Tickets --
License MIT
Doc PR --

I want to streamline the experience, creating new notifier transports. Maybe such exceptions fit well, as we are planing to get more and more transports and don't want to "pollute" the transports itself with repeatable code.

Please let me know if you are open to have such exceptions as I would like to introduce more of them for unsupported options for example and if this should be considered a new feature or it should be applied against 5.1?

I am not sure about the signature and the name of the new UnsupportedMessageTypeException.

Cheers

@fabpot
Copy link
Member

fabpot commented Dec 8, 2020

Can you check the failed tests?
By the way, that's a new feature :)

@OskarStark OskarStark force-pushed the named-notifier-exceptions branch from 38157fc to 774f6f8 Compare December 8, 2020 07:07
@OskarStark
Copy link
Contributor Author

Can you check the failed tests?

Yes will do 👍

By the way, that's a new feature :)

I thought that, thanks!

Any preference for the signature and shall we use UnsupportedMessageException or is ...MessageType... fine, because its a new term in notifier scope.

@OskarStark OskarStark force-pushed the named-notifier-exceptions branch 4 times, most recently from 6809c42 to 312920d Compare December 8, 2020 11:02
@OskarStark
Copy link
Contributor Author

Tests fixed, the lat one is unrelated ❗

fabbot.io failure seems unrelated, and if you want can be fixed in a separate PR:

diff -ru src/Symfony/Component/Notifier/Bridge/RocketChat/RocketChatTransport.php src/Symfony/Component/Notifier/Bridge/RocketChat/RocketChatTransport.php
--- src/Symfony/Component/Notifier/Bridge/RocketChat/RocketChatTransport.php	2020-12-08 11:06:07.893047631 +0000
+++ src/Symfony/Component/Notifier/Bridge/RocketChat/RocketChatTransport.php	2020-12-08 11:06:09.624988949 +0000
@@ -77,12 +77,12 @@
         );
 
         if (200 !== $response->getStatusCode()) {
-            throw new TransportException(sprintf('Unable to post the RocketChat message: %s.', $response->getContent(false)), $response);
+            throw new TransportException(sprintf('Unable to post the RocketChat message: "%s".', $response->getContent(false)), $response);
         }
 
         $result = $response->toArray(false);
         if (!$result['success']) {
-            throw new TransportException(sprintf('Unable to post the RocketChat message: %s.', $result['error']), $response);
+            throw new TransportException(sprintf('Unable to post the RocketChat message: "%s".', $result['error']), $response);
         }
     }
 }
diff -ru src/Symfony/Component/Notifier/Bridge/Telegram/TelegramTransport.php src/Symfony/Component/Notifier/Bridge/Telegram/TelegramTransport.php
--- src/Symfony/Component/Notifier/Bridge/Telegram/TelegramTransport.php	2020-12-08 11:06:08.584024219 +0000
+++ src/Symfony/Component/Notifier/Bridge/Telegram/TelegramTransport.php	2020-12-08 11:06:09.624988949 +0000
@@ -78,7 +78,7 @@
         if (200 !== $response->getStatusCode()) {
             $result = $response->toArray(false);
 
-            throw new TransportException('Unable to post the Telegram message: '.$result['description'].sprintf(' (code %s).', $result['error_code']), $response);
+            throw new TransportException('Unable to post the Telegram message: '.$result['description'].sprintf(' (code "%s").', $result['error_code']), $response);
         }
     }
 }

@jderusse jderusse added this to the 5.x milestone Dec 8, 2020
@OskarStark OskarStark force-pushed the named-notifier-exceptions branch from 312920d to fa39cd6 Compare December 9, 2020 08:38
@OskarStark OskarStark force-pushed the named-notifier-exceptions branch 2 times, most recently from 7cab59b to 70c3093 Compare December 11, 2020 10:35
@OskarStark OskarStark changed the title [Notifier] UnsupportedMessageTypeException for notifier transports [Notifier][DX] UnsupportedMessageTypeException for notifier transports Dec 11, 2020
@carsonbot carsonbot changed the title [Notifier][DX] UnsupportedMessageTypeException for notifier transports [Notifier] [DX] UnsupportedMessageTypeException for notifier transports Dec 11, 2020
@jderusse jderusse force-pushed the named-notifier-exceptions branch from f40a051 to cf1d352 Compare December 11, 2020 20:40
@jderusse
Copy link
Member

Thank you @OskarStark.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants