8000 fix: Send correct key for exc errno · etherscan-io/sentry-python@2f54872 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2f54872

Browse files
committed
fix: Send correct key for exc errno
1 parent 0795787 commit 2f54872

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

sentry_sdk/utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,9 @@ def single_exception_from_error_tuple(
495495

496496
if errno is not None:
497497
mechanism = mechanism or {}
498-
mechanism_meta = mechanism.setdefault("meta", {})
499-
mechanism_meta.setdefault("errno", {"code": errno})
498+
mechanism.setdefault("meta", {}).setdefault("errno", {}).setdefault(
499+
"number", errno
500+
)
500501

501502
if client_options is None:
502503
with_locals = True

tests/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ def inner(event):
8585
).decode("utf-8")
8686
)
8787
_no_errors_in_semaphore_response(output)
88+
output.pop("_meta", None)
8889

8990
return inner
9091

tests/test_client.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,3 +459,18 @@ def __repr__(self):
459459
event["exception"]["values"][0]["stacktrace"]["frames"][0]["vars"]["a"]
460460
== "<broken repr>"
461461
)
462+
463+
464+
def test_errno_errors(sentry_init, capture_events):
465+
sentry_init()
466+
events = capture_events()
467+
468+
class Foo(Exception):
469+
errno = 69
470+
471+
capture_exception(Foo())
472+
473+
event, = events
474+
475+
exception, = event["exception"]["values"]
476+
assert exception["mechanism"]["meta"]["errno"]["number"] == 69

0 commit comments

Comments
 (0)
0