# What this PR does Introduces BaseFailed exception for phone_notificator. # Why We need to somehow distinguish errors we want to be notified - like network errors or invalid twilio credentials (I will call them "real" errors) and errors we want to share with user, but don't want to be paged ( I will call them "fake" errors). To do that I added "graceful_msg" to all Failed... exceptions. If details field is present - it mean we can return 400 code with the message, if not - 500 code. So, "real" errors will raise Failed... exception, while "fake" will add "graceful_msg". # TODO handle exceptions handled here https://github.com/grafana/oncall/pull/2065 ## Checklist - [ ] Unit, integration, and e2e (if applicable) tests updated - [x] Documentation added (or `pr:no public docs` PR label added if not required) - [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not required) --------- Co-authored-by: Michael Derynck <michael.derynck@grafana.com>
50 lines
1.1 KiB
Python
50 lines
1.1 KiB
Python
class BaseFailed(Exception):
|
|
"""
|
|
Failed is base exception for all Failed... exceptions.
|
|
This exception is indicates error while performing some phone notification operation.
|
|
Optionally can contain graceful_msg attribute. When graceful_msg is provided it mean that error on provider side is
|
|
not our fault, but some provider error (number is blocked, fraud guard, ...).
|
|
By default, graceful_msg is None - it means that error is our fault (network problems, invalid configuration,...).
|
|
|
|
Attributes:
|
|
graceful_msg: string with some details about exception which can be exposed to caller.
|
|
"""
|
|
|
|
def __init__(self, graceful_msg=None):
|
|
self.graceful_msg = graceful_msg
|
|
|
|
|
|
class FailedToMakeCall(BaseFailed):
|
|
pass
|
|
|
|
|
|
class FailedToSendSMS(BaseFailed):
|
|
pass
|
|
|
|
|
|
class FailedToStartVerification(BaseFailed):
|
|
pass
|
|
|
|
|
|
class FailedToFinishVerification(BaseFailed):
|
|
pass
|
|
|
|
|
|
class NumberNotVerified(Exception):
|
|
pass
|
|
|
|
|
|
class NumberAlreadyVerified(Exception):
|
|
pass
|
|
|
|
|
|
class ProviderNotSupports(Exception):
|
|
pass
|
|
|
|
|
|
class CallsLimitExceeded(Exception):
|
|
pass
|
|
|
|
|
|
class SMSLimitExceeded(Exception):
|
|
pass
|