-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ref(sentry apps): Use new error design for sentry app errors #83355
Changes from all commits
4e5edcd
7eb854c
6799898
260020a
fadefc9
90751f4
c1cded0
bec598f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
from enum import Enum | ||
from typing import Any | ||
|
||
|
||
class SentryAppErrorType(Enum): | ||
|
@@ -7,43 +8,38 @@ class SentryAppErrorType(Enum): | |
SENTRY = "sentry" | ||
|
||
|
||
# Represents a user/client error that occured during a Sentry App process | ||
class SentryAppError(Exception): | ||
error_type = SentryAppErrorType.CLIENT | ||
status_code = 400 | ||
class SentryAppBaseError(Exception): | ||
error_type: SentryAppErrorType | ||
status_code: int | ||
|
||
def __init__( | ||
self, | ||
error: Exception | None = None, | ||
message: str, | ||
status_code: int | None = None, | ||
public_context: dict[str, Any] | None = None, | ||
webhook_context: dict[str, Any] | None = None, | ||
) -> None: | ||
if status_code: | ||
self.status_code = status_code | ||
self.status_code = status_code or self.status_code | ||
# Info that gets sent only to the integrator via webhook | ||
self.public_context = public_context or {} | ||
# Info that gets sent to the end user via endpoint Response AND sent to integrator | ||
self.webhook_context = webhook_context or {} | ||
self.message = message | ||
|
||
|
||
# Represents a user/client error that occured during a Sentry App process | ||
class SentryAppError(SentryAppBaseError): | ||
error_type = SentryAppErrorType.CLIENT | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are you using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we need error_type in the future for Alert Rule Action UI process/ creation because it's an RPC method and we need to send error context in the RPC response. |
||
status_code = 400 | ||
|
||
|
||
# Represents an error caused by a 3p integrator during a Sentry App process | ||
class SentryAppIntegratorError(Exception): | ||
class SentryAppIntegratorError(SentryAppBaseError): | ||
error_type = SentryAppErrorType.INTEGRATOR | ||
status_code = 400 | ||
|
||
def __init__( | ||
self, | ||
error: Exception | None = None, | ||
status_code: int | None = None, | ||
) -> None: | ||
if status_code: | ||
self.status_code = status_code | ||
|
||
|
||
# Represents an error that's our (sentry's) fault | ||
class SentryAppSentryError(Exception): | ||
class SentryAppSentryError(SentryAppBaseError): | ||
error_type = SentryAppErrorType.SENTRY | ||
status_code = 500 | ||
|
||
def __init__( | ||
self, | ||
error: Exception | None = None, | ||
status_code: int | None = None, | ||
) -> None: | ||
if status_code: | ||
self.status_code = status_code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you planning on sending public context and webhook context separately in here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes the idea is to make some
send_webhook_context_to_integrators(exception)
and call that here.webhook_context
&public_context
will both go to integrators via that send function.