Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
Merge pull request #856 from mozilla-services/bug/855
Browse files Browse the repository at this point in the history
bug: Use log.failure() to better track exceptions in APNS
  • Loading branch information
bbangert authored Mar 31, 2017
2 parents 4128d94 + 8aa510d commit 987f31d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 7 additions & 2 deletions autopush/router/apnsrouter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from hyper.http20.exceptions import ConnectionError, HTTP20Error
from twisted.internet.threads import deferToThread
from twisted.logger import Logger
from twisted.python.failure import Failure

from autopush.exceptions import RouterException
from autopush.router.apns2 import (
Expand Down Expand Up @@ -146,18 +147,22 @@ def _route(self, notification, router_data):
try:
apns_client.send(router_token=router_token, payload=payload,
apns_id=apns_id)
except ConnectionError:
except ConnectionError as ex:
self.ap_settings.metrics.increment(
"updates.client.bridge.apns.connection_err",
self._base_tags
)
self.log.error("Connection Error sending to APNS",
log_failure=Failure(ex))
raise RouterException(
"Server error",
status_code=502,
response_body="APNS returned an error processing request",
log_exception=False,
)
except HTTP20Error:
except HTTP20Error as ex:
self.log.error("HTTP2 Error sending to APNS",
log_failure=Failure(ex))
raise RouterException(
"Server error",
status_code=502,
Expand Down
2 changes: 2 additions & 0 deletions autopush/tests/test_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ def raiser(*args, **kwargs):
eq_(e.exception.response_body, 'APNS returned an error '
'processing request')
eq_(e.exception.status_code, 502)
self.flushLoggedErrors()

@inlineCallbacks
def test_route_notification(self):
Expand Down Expand Up @@ -230,6 +231,7 @@ def throw(*args, **kwargs):
eq_(ex.exception.message, "Server error")
eq_(ex.exception.response_body, 'APNS returned an error processing '
'request')
self.flushLoggedErrors()

def test_too_many_connections(self):
rr = self.router.apns['firefox']
Expand Down

0 comments on commit 987f31d

Please sign in to comment.