In my use case the user is allowed to upload a single file. After the upload succeeded, I check the file for a number of properties. Should my program fail to verify one of the properties, I want to prompt the user with an error directly in the Upload component.
Is there a way I can manually fire an error like this, so I can hook to it via the FailedListener?
Thanks in advance!
Did you check the logs? There must be an Exception
The error message is just an example. I want to be able to throw a custom error message after I did my own checks on the uploaded file. The error should then appear in the same location as indicated in the screenshot.
I don’t think that’s possible
You can only set three error messages through UploadI18 ServerUnavailable, UnexpectedServerError and Forbidden. Here is an example
UploadI18N i18n = new UploadI18N();
i18n.setDropFiles(new UploadI18N.DropFiles()
.setOne(translation().translate("Datei hier ablegen")).setMany(translation().translate("Dateien hier ablegen")))
.setAddFiles(new UploadI18N.AddFiles().setOne(translation().translate("Datei hochladen")).setMany(translation().translate("Dateien hochladen")))
.setError(new UploadI18N.Error()
.setTooManyFiles(translation().translate("Zuviele Dateien hochgeladen!"))
.setFileIsTooBig(translation().translate("Die Datei ist zu gross!"))
.setIncorrectFileType(translation().translate("Die Datei hat den falschen Typ!")))
.setUploading(new UploadI18N.Uploading()
.setStatus(new UploadI18N.Uploading.Status()
.setConnecting(translation().translate("Verbinden..."))
.setStalled(translation().translate("Blockiert"))
.setProcessing(translation().translate("Verarbeitung...")))
.setRemainingTime(
new UploadI18N.Uploading.RemainingTime()
.setPrefix(translation().translate("Verbleibende Zeit:"))
.setUnknown(translation().translate("Verbleibende Zeit unbekannt.")))
.setError(new UploadI18N.Uploading.Error()
.setServerUnavailable(translation().translate("Der Server ist nicht verfügbar!"))
.setUnexpectedServerError(translation().translate("Es ist ein unerwarteter Fehler aufgetreten!"))
.setForbidden(translation().translate("Verboten"))));
I assume the error handling on these is handled internally though right? Or could I throw the Forbidden exception myself after checking the file?
I assume that they are caught by the web component when the server communiation fails based on the HTTP Status code