From c7cd2fcf3331426277a0e2d07512272149bae467 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Tue, 12 May 2020 01:49:56 +0200 Subject: xep_0363: pass more information to FileTooBig exception MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- slixmpp/plugins/xep_0363/http_upload.py | 6 ++++-- 1 file 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] -- cgit v1.2.3