I am developing a web app where select users can upload certain documents pertaining to an event, that general users can then download as required. I am having some difficulty with the code that will download the document. Specifically, when a document was manually removed, I have a try catch logic to skip the download. The problem is however that I don’t reach the Catch section, I have a unhandled exception (nilobject exception, which is what I was trying to catch) in the try section.
Usually, such issues result from my code being incorrect, but I don’t see what I could be doing wrong. So, here it is. What am I doing wrong?
The user selects a file name in a listbox. The file was previously saved in a folder that is specific to the environment. :
If Me.listindex > -1 Then
Dim SavedFile As folderitem
Dim UploadedFile As String
UploadedFile = Me.cell(Me.listindex,0)
SavedFile = App.ExecutableFile.Parent.Child("UploadedDocuments") ' get to the uploaded documents folder
SavedFile = SavedFile.child(Session.ZENV) ' Reach the environment subfolder
Try
SavedFile = SavedFile.Child(UploadedFile) ' the actual file to download <---this is where the application fires the nilobjectexception
Catch err As RuntimeException
If err IsA NilObjectException Then
MsgBox ("Le fichier n'est pas disponible.")
Return
Else
Return ' do nothing - early return --- need to build logging here
End If
End Try
..... (method continues)
This is with 2017R3 on Windows 10 X64 (the app is compiled 32 bit)
Thanks in advance.