Perspective File Upload - No error catching/reporting for user

Hey, I’m on Edge (8.1.18) and I’m using the File Upload control in Perspective in a Workstation Kiosk environment.

I noticed that if I simulate an error on the onFileReceived event.file.copyTo() method, such as a broken file path or permission denied, I cannot capture the exception with a try block. Instead, it is only captured by the Gateway since apparently this exception isn’t raised to the calling function. Also, which is slightly more concerning, the control reports that the upload was a success, despite it failing to copy the file.

I have some workarounds, but I was wondering if I am missing anything here, and if not, I’d like to request that in a future release the control raises the exception to the caller.

Thanks!

Two considerations:

  1. Java exceptions and python exceptions behave differently. To reliably capture both, you need two except: clauses.

  2. All scripts in Perspective run on the gateway, so will always report exceptions to the gateway log. Production websites do the same–exceptions showing in the browser are a security leak.

To also expand a little bit, the component is reporting success on receiving the file and entering the onFileReceived Event. Problems within the onFileReceived Event do not play into what the component reports; errors/exceptions encountered there must be conveyed by some other UI put in place by the Designer of the project.

2 Likes

Thanks, pturmel. Your 1st point was the solution. For the benefit of other viewers of this topic, to capture the Java exceptions raised by the controls, you’ll need to import java and use an except statement:

import java
	
try:
	# code here
	
except java.lang.Exception as err:
	# handle error