Skip to content

Commit 2bb77a9

Browse files
committed
Merge pull request #319 from RickyCook/rollbar-ignore-some-exceptions
Rollbar ignore some exceptions
2 parents ea1528e + 08eddb2 commit 2bb77a9

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

dockci/api/exceptions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
class BaseActionExceptionMixin(HTTPException):
66
""" An HTTP exception for when an action can't be performed """
77
response = None
8+
no_rollbar = True
89

910
def __init__(self, action=None):
1011
super(BaseActionExceptionMixin, self).__init__()
@@ -39,6 +40,7 @@ class WrappedException(HTTPException):
3940
Wraps an exception in HTTPException so that it can have a status code
4041
"""
4142
response = None
43+
no_rollbar = True
4244

4345
def __init__(self, ex):
4446
super(WrappedException, self).__init__()

dockci/server.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,14 @@ def app_init():
122122
app_init_workers()
123123

124124

125+
def wrapped_report_exception(app, exception):
126+
""" Wrapper for ``report_exception`` to ignore some exceptions """
127+
if getattr(exception, 'no_rollbar', False):
128+
return
129+
130+
return rollbar.contrib.flask.report_exception(app, exception)
131+
132+
125133
def app_init_rollbar():
126134
""" Initialize Rollbar for error/exception reporting """
127135
try:
@@ -138,9 +146,7 @@ def app_init_rollbar():
138146
allow_logging_basic_config=False,
139147
)
140148

141-
flask.got_request_exception.connect(
142-
rollbar.contrib.flask.report_exception, APP,
143-
)
149+
flask.got_request_exception.connect(wrapped_report_exception, APP)
144150

145151

146152
def app_init_workers():

0 commit comments

Comments
 (0)