Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# to the changes made since it was copied.
class SlackClientError(Exception):
"""
Base exception for all errors raised by the SlackClient library
"""
def __init__(self, msg: str) -> None:
super(SlackClientError, self).__init__(msg)
def __str__(self) -> str:
reply = getattr(self, 'reply', None)
msg = getattr(self, 'msg', None)
return f'message={msg} reply={reply}'
class SlackConnectionError(SlackClientError):
def __init__(self, message='', reply=None) -> None:
super(SlackConnectionError, self).__init__(message)
self.reply = reply
class SlackLoginError(SlackClientError):
def __init__(self, message='', reply=None) -> None:
super(SlackLoginError, self).__init__(message)
self.reply = reply
def __init__(self, msg=None):
if msg is None:
# default error message
msg = "An error occurred in the SlackClient library"
super(SlackClientError, self).__init__(msg)
def __init__(self, msg: str) -> None:
super(SlackClientError, self).__init__(msg)
response_json["headers"] = dict(response.headers)
return json.dumps(response_json)
# TODO: Move the error types defined below into the .exceptions namespace. This would be a semver
# major change because any clients already referencing these types in order to catch them
# specifically would need to deal with the symbol names changing.
class SlackConnectionError(SlackClientError):
def __init__(self, message="", reply=None):
super(SlackConnectionError, self).__init__(message)
self.reply = reply
class SlackLoginError(SlackClientError):
def __init__(self, message="", reply=None):
super(SlackLoginError, self).__init__(message)
self.reply = reply
or
u'{"ok":false,"error":"channel_not_found"}'
See here for more information on responses: https://api.slack.com/web
"""
response = self.api_requester.do(self.token, method, kwargs, timeout=timeout)
response_json = json.loads(response.text)
response_json["headers"] = dict(response.headers)
return json.dumps(response_json, ensure_ascii=False)
# TODO: Move the error types defined below into the .exceptions namespace. This would be a semver
# major change because any clients already referencing these types in order to catch them
# specifically would need to deal with the symbol names changing.
class SlackConnectionError(SlackClientError):
def __init__(self, message='', reply=None):
super(SlackConnectionError, self).__init__(message)
self.reply = reply
class SlackLoginError(SlackClientError):
def __init__(self, message='', reply=None):
super(SlackLoginError, self).__init__(message)
self.reply = reply
class ParseResponseError(SlackClientError, ValueError):
"""
Error raised when responses to Web API methods cannot be parsed as valid JSON
"""
def __init__(self, response_body, original_exception):
super(ParseResponseError, self).__init__(
"Slack API response body could not be parsed: {0}. Original exception: {1}".format(
response_body, original_exception
)
)
self.response_body = response_body
self.original_exception = original_exception
class TokenRefreshError(SlackClientError):
"""
This exception is rasied when a token related error occurs within the client
def __init__(self, msg: str) -> None:
super(SlackClientError, self).__init__(msg)
def __str__(self) -> str:
reply = getattr(self, 'reply', None)
msg = getattr(self, 'msg', None)
return f'message={msg} reply={reply}'
class SlackConnectionError(SlackClientError):
def __init__(self, message='', reply=None) -> None:
super(SlackConnectionError, self).__init__(message)
self.reply = reply
class SlackLoginError(SlackClientError):
def __init__(self, message='', reply=None) -> None:
super(SlackLoginError, self).__init__(message)
self.reply = reply
response_json = json.loads(response.text)
response_json["headers"] = dict(response.headers)
return json.dumps(response_json, ensure_ascii=False)
# TODO: Move the error types defined below into the .exceptions namespace. This would be a semver
# major change because any clients already referencing these types in order to catch them
# specifically would need to deal with the symbol names changing.
class SlackConnectionError(SlackClientError):
def __init__(self, message='', reply=None):
super(SlackConnectionError, self).__init__(message)
self.reply = reply
class SlackLoginError(SlackClientError):
def __init__(self, message='', reply=None):
super(SlackLoginError, self).__init__(message)
self.reply = reply
class SlackClientError(Exception):
"""
Base exception for all errors raised by the SlackClient library
"""
def __init__(self, msg=None):
if msg is None:
# default error message
msg = "An error occurred in the SlackClient library"
super(SlackClientError, self).__init__(msg)
class ParseResponseError(SlackClientError, ValueError):
"""
Error raised when responses to Web API methods cannot be parsed as valid JSON
"""
def __init__(self, response_body, original_exception):
super(ParseResponseError, self).__init__(
"Slack API response body could not be parsed: {0}. Original exception: {1}".format(
response_body, original_exception
)
)
self.response_body = response_body
self.original_exception = original_exception
class TokenRefreshError(SlackClientError):
"""
This exception is rasied when a token related error occurs within the client
u'{"ok":false,"error":"channel_not_found"}'
See here for more information on responses: https://api.slack.com/web
"""
response = self.api_requester.do(token, request, kwargs, timeout=timeout)
response_json = json.loads(response.text)
response_json["headers"] = dict(response.headers)
return json.dumps(response_json)
# TODO: Move the error types defined below into the .exceptions namespace. This would be a semver
# major change because any clients already referencing these types in order to catch them
# specifically would need to deal with the symbol names changing.
class SlackConnectionError(SlackClientError):
def __init__(self, message="", reply=None):
super(SlackConnectionError, self).__init__(message)
self.reply = reply
class SlackLoginError(SlackClientError):
def __init__(self, message="", reply=None):
super(SlackLoginError, self).__init__(message)
self.reply = reply