Skip to content

Commit

Permalink
update sa errors to handle APIException errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Christinarlong committed Dec 16, 2024
1 parent 7b07db7 commit d9ca71d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/sentry/sentry_apps/utils/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Any

import sentry_sdk
from rest_framework.exceptions import APIException
from rest_framework.response import Response


Expand All @@ -19,9 +20,13 @@ class SentryAppError(Exception):

def __init__(
self,
error: Exception | None = None,
error: Exception | APIException | None = None,
status_code: int | None = None,
) -> None:
if isinstance(error, APIException):
# APIException's default serialization will return a dict, we just want the message
self.args = error.args or error.default_detail

if status_code:
self.status_code = status_code

Expand All @@ -33,9 +38,13 @@ class SentryAppIntegratorError(Exception):

def __init__(
self,
error: Exception | None = None,
error: Exception | APIException | None = None,
status_code: int | None = None,
) -> None:
if isinstance(error, APIException):
# APIException's default serialization will return a dict, we just want the message
self.args = error.args or error.default_detail

if status_code:
self.status_code = status_code

Expand Down

0 comments on commit d9ca71d

Please sign in to comment.