diff options
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | 2018-11-20 07:44:09 +0100 |
---|---|---|
committer | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | 2018-11-20 07:44:09 +0100 |
commit | 33370e42f11d7cb55b0d7029cc5516f1370bbca4 (patch) | |
tree | f193c70d936251bd4f45d9be3f979763fba8800c | |
parent | 4699861925fa9201e0b65a0b761181daefbc0cd3 (diff) | |
download | slixmpp-33370e42f11d7cb55b0d7029cc5516f1370bbca4.tar.gz slixmpp-33370e42f11d7cb55b0d7029cc5516f1370bbca4.tar.bz2 slixmpp-33370e42f11d7cb55b0d7029cc5516f1370bbca4.tar.xz slixmpp-33370e42f11d7cb55b0d7029cc5516f1370bbca4.zip |
XEP-0363: Use a specific exception for HTTP errors
-rw-r--r-- | slixmpp/plugins/xep_0363/http_upload.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/slixmpp/plugins/xep_0363/http_upload.py b/slixmpp/plugins/xep_0363/http_upload.py index 79a42412..266fc656 100644 --- a/slixmpp/plugins/xep_0363/http_upload.py +++ b/slixmpp/plugins/xep_0363/http_upload.py @@ -30,6 +30,10 @@ class UploadServiceNotFound(FileUploadError): class FileTooBig(FileUploadError): pass +class HTTPError(FileUploadError): + def __str__(self): + return 'Could not upload file: %d (%s)' % (self.args[0], self.args[1]) + class XEP_0363(BasePlugin): ''' This plugin only supports Python 3.5+ ''' @@ -149,7 +153,7 @@ class XEP_0363(BasePlugin): headers=headers, timeout=timeout) if response.status >= 400: - raise FileUploadError("could not upload file: %d (%s)" % (response.status, await response.text())) + raise HTTPError(response.status, await response.text()) log.info('Response code: %d (%s)', response.status, await response.text()) response.close() return slot['get']['url'] |