Skip to content
Browse files

Don't put ops-related exceptions in log_q.

They're transient situations outside the app's domain
and not bugs. (though they probably do indicate a place
where we should be more robust, so don't ignore them
entirely.)
  • Loading branch information...
1 parent f1c6f48 commit 5df49b5a38410f13e24ee7b20458407a063ebb3e @spladug spladug committed with Logan Hanks
Showing with 16 additions and 1 deletion.
  1. +16 −1 r2/r2/lib/base.py
View
17 r2/r2/lib/base.py
@@ -20,6 +20,10 @@
# CondeNet, Inc. All Rights Reserved.
################################################################################
+import _pylibmc
+import pycassa.pool
+import sqlalchemy.exc
+
from pylons import Response, c, g, request, session, config
from pylons.controllers import WSGIController, Controller
from pylons.controllers.util import abort
@@ -30,6 +34,7 @@
from r2.lib.template_helpers import get_domain
from utils import storify, string2js, read_http_date
from r2.lib.log import log_exception
+import r2.lib.db.thing
import re, hashlib
from urllib import quote
@@ -37,6 +42,16 @@
import sys
+OPERATIONAL_EXCEPTIONS = (_pylibmc.MemcachedError,
+ r2.lib.db.thing.NotFound,
+ sqlalchemy.exc.OperationalError,
+ sqlalchemy.exc.IntegrityError,
+ pycassa.pool.AllServersUnavailable,
+ pycassa.pool.NoConnectionAvailable,
+ pycassa.pool.MaximumRetryException,
+ )
+
+
#TODO hack
import logging
from r2.lib.utils import UrlParser, query_string
@@ -113,7 +128,7 @@ def __call__(self, environ, start_response):
try:
res = WSGIController.__call__(self, environ, start_response)
except Exception as e:
- if g.exception_logging:
+ if g.exception_logging and not isinstance(e, OPERATIONAL_EXCEPTIONS):
try:
log_exception(e, *sys.exc_info())
except Exception as f:

0 comments on commit 5df49b5

Please sign in to comment.
Something went wrong with that request. Please try again.