File tree Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -717,10 +717,12 @@ def get_error_message(exc_value):
717717 getattr (exc_value , "message" , "" )
718718 or getattr (exc_value , "detail" , "" )
719719 or safe_str (exc_value )
720- )
721- notes = getattr (exc_value , "__notes__" , [])
722- if notes :
723- value = "\n " .join ([value ] + [safe_str (note ) for note in notes ])
720+ ) # type: str
721+
722+ notes = getattr (exc_value , "__notes__" , None ) # type: object
723+ if isinstance (notes , list ) and len (notes ) > 0 :
724+ value += "\n " + "\n " .join (note for note in notes if isinstance (note , str ))
725+
724726 return value
725727
726728
Original file line number Diff line number Diff line change @@ -1008,13 +1008,14 @@ def test_notes(sentry_init, capture_events):
10081008 try :
10091009 e = ValueError ("aha!" )
10101010 e .add_note ("Test 123" )
1011+ e .add_note ("another note" )
10111012 raise e
10121013 except Exception :
10131014 capture_exception ()
10141015
10151016 (event ,) = events
10161017
1017- assert event ["exception" ]["values" ][0 ]["value" ] == "aha!\n Test 123"
1018+ assert event ["exception" ]["values" ][0 ]["value" ] == "aha!\n Test 123\n another note "
10181019
10191020
10201021@pytest .mark .skipif (sys .version_info < (3 , 11 ), reason = "add_note() not supported" )
@@ -1033,13 +1034,11 @@ def __str__(self):
10331034 e .add_note ("note 1" )
10341035 e .__notes__ .append (Note2 ()) # type: ignore
10351036 e .add_note ("note 3" )
1037+ e .__notes__ .append (2 ) # type: ignore
10361038 raise e
10371039 except Exception :
10381040 capture_exception ()
10391041
10401042 (event ,) = events
10411043
1042- assert (
1043- event ["exception" ]["values" ][0 ]["value" ]
1044- == "aha!\n note 1\n <broken repr>\n note 3"
1045- )
1044+ assert event ["exception" ]["values" ][0 ]["value" ] == "aha!\n note 1\n note 3"
You can’t perform that action at this time.
0 commit comments