mirror of
https://github.com/jlengrand/bugsink.git
synced 2026-03-10 08:01:17 +00:00
Factor out the idea (exception -> type_, value) what we have
This commit is contained in:
@@ -14,7 +14,8 @@ def get_issue_grouper_for_data(data):
|
||||
else:
|
||||
eventtype = DefaultEvent()
|
||||
|
||||
title = eventtype.get_title(data)
|
||||
type_, value = eventtype.get_exception_type_and_value(data)
|
||||
title = get_title_for_exception_type_and_value(type_, value)
|
||||
transaction = force_str(data.get("transaction") or "")
|
||||
fingerprint = data.get("fingerprint")
|
||||
event_type_name = type(eventtype).__name__
|
||||
@@ -28,6 +29,16 @@ def get_issue_grouper_for_data(data):
|
||||
return default_issue_grouper(title, transaction, event_type_name)
|
||||
|
||||
|
||||
def get_title_for_exception_type_and_value(type_, value):
|
||||
if not value:
|
||||
return type_
|
||||
|
||||
if not isinstance(value, str):
|
||||
value = str(value)
|
||||
|
||||
return "{}: {}".format(type_, value.splitlines()[0])
|
||||
|
||||
|
||||
# utilities related to storing and retrieving release-versions; we use the fact that sentry (and we've adopted their
|
||||
# limitation) disallows the use of newlines in release-versions, so we can use newlines as a separator
|
||||
|
||||
|
||||
@@ -8,13 +8,13 @@ class DefaultEvent:
|
||||
actually say that this is basically the LogMessageEvent.
|
||||
"""
|
||||
|
||||
def get_title(self, data):
|
||||
def get_exception_type_and_value(self, data):
|
||||
message = strip(
|
||||
get_path(data, "logentry", "message")
|
||||
or get_path(data, "logentry", "formatted")
|
||||
)
|
||||
|
||||
if message:
|
||||
return truncatechars(message.splitlines()[0], 100)
|
||||
return truncatechars(message.splitlines()[0], 100), ""
|
||||
|
||||
return "<unlabeled event>"
|
||||
return "<unlabeled event>", ""
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
from django.template.defaultfilters import truncatechars
|
||||
|
||||
from sentry.stacktraces.functions import get_function_name_for_frame
|
||||
from sentry.stacktraces.processing import get_crash_frame_from_event_data
|
||||
from sentry.utils.safe import get_path, trim
|
||||
@@ -18,14 +16,14 @@ def get_crash_location(data):
|
||||
|
||||
class ErrorEvent:
|
||||
|
||||
def get_title(self, data):
|
||||
def get_exception_type_and_value(self, data):
|
||||
if isinstance(data.get("exception"), list):
|
||||
if len(data["exception"]) == 0:
|
||||
return "<unknown>"
|
||||
return "<unknown>", ""
|
||||
|
||||
exception = get_path(data, "exception", "values", -1)
|
||||
if not exception:
|
||||
return "<unknown>"
|
||||
return "<unknown>", ""
|
||||
|
||||
value = trim(get_path(exception, "value", default=""), 1024)
|
||||
|
||||
@@ -36,15 +34,9 @@ class ErrorEvent:
|
||||
if get_path(exception, "mechanism", "synthetic"):
|
||||
_, function = get_crash_location(data)
|
||||
if function:
|
||||
return function
|
||||
return "<unknown>"
|
||||
return function, ""
|
||||
return "<unknown>", ""
|
||||
|
||||
type_ = trim(get_path(exception, "type", default="Error"), 128)
|
||||
|
||||
if not value:
|
||||
return type_
|
||||
|
||||
if not isinstance(value, str):
|
||||
value = str(value)
|
||||
|
||||
return "{}: {}".format(type_, truncatechars(value.splitlines()[0]))
|
||||
return type_, value
|
||||
|
||||
Reference in New Issue
Block a user