summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2020-05-12 01:53:00 +0200
committermathieui <mathieui@mathieui.net>2020-05-12 01:53:00 +0200
commit9ace053992f12af62680a0b3f20f3291150e8935 (patch)
tree2552544d9c2c81b6b928c53b8aa7b2adf3e843bb
parente57289358f58e966e4b49a80f947ddbc4a16b1f8 (diff)
parentc7cd2fcf3331426277a0e2d07512272149bae467 (diff)
downloadslixmpp-9ace053992f12af62680a0b3f20f3291150e8935.tar.gz
slixmpp-9ace053992f12af62680a0b3f20f3291150e8935.tar.bz2
slixmpp-9ace053992f12af62680a0b3f20f3291150e8935.tar.xz
slixmpp-9ace053992f12af62680a0b3f20f3291150e8935.zip
Merge branch 'upload-filetoobig' into 'master'
xep_0363: pass more information to FileTooBig exception See merge request poezio/slixmpp!50
-rw-r--r--slixmpp/plugins/xep_0363/http_upload.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/slixmpp/plugins/xep_0363/http_upload.py b/slixmpp/plugins/xep_0363/http_upload.py
index 7b9ccc7d..a833a9c9 100644
--- a/slixmpp/plugins/xep_0363/http_upload.py
+++ b/slixmpp/plugins/xep_0363/http_upload.py
@@ -28,7 +28,9 @@ class UploadServiceNotFound(FileUploadError):
pass
class FileTooBig(FileUploadError):
- pass
+ def __str__(self):
+ return 'File size too large: {} (max: {} bytes)' \
+ .format(self.args[0], self.args[1])
class HTTPError(FileUploadError):
def __str__(self):
@@ -126,7 +128,7 @@ class XEP_0363(BasePlugin):
input_file.seek(0)
if size > self.max_file_size:
- raise FileTooBig()
+ raise FileTooBig(size, self.max_file_size)
if content_type is None:
content_type = guess_type(filename)[0]