Skip to content
This repository has been archived by the owner on Sep 27, 2019. It is now read-only.

emit NotificationFailed on critical failure #4

Closed
wants to merge 2 commits into from

Conversation

timbroder
Copy link

Taking inspiration from here and here this modifies the channel to emit the NotificationFailed if there is a critial failure.

I'm using this to back-peddle if I try to send a message via email to a user's email and get back:

FtwSoft/NotificationChannels/Intercom/Exceptions/RequestException with message 'Client error: `POST https://api.intercom.io/messages` resulted in a `409 Conflict` response:
{"type":"error.list","request_id":"0002caq9aec3fsla24r0","errors":[{"code":"conflict","message":"Multiple existing users (truncated...)

I'm happy to add tests for this if you want, but the IntercomChannelTest test didn't seem to have access to the app, facades, or event mocks. Could use some guidance

Thanks

Copy link
Owner

@ftw-soft ftw-soft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also. Travis CI broken in this PR

@@ -76,6 +77,12 @@ public function send($notifiable, Notification $notification): void
$message->toArray()
);
} catch (BadResponseException $exception) {
event(new NotificationFailed($notifiable, $notification, $this, [
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't have to do like that. This is unattended behavior, also event is not obvious dependency, there is EventDispatcher class exists for that
You must catch this Exception on your business layer

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you point me the proper way to catch that? In my testing, once the Notification has been given over to Laravel there's no way to catch errors it throws

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to read manual and internal Laravel code more accurately.
Unfortunately, I can't help you with this now

@ftw-soft
Copy link
Owner

There is no obvious reason to accept this pull request now.

@ftw-soft ftw-soft closed this Jul 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants