M mw71 Well-Known Member Licensed User Longtime User Sep 5, 2019 #1 Hi, with this Code i get a List from the FTP Server: Code: Copy FTP.Initialize("FTP",server,port,user,passwort) 'server,port,user,passwort-> string variable FTP.PassiveMode=True FTP.List("/") Wait For FTP_ListCompleted (ServerPath As String, Success As Boolean, FolderS() As FTPEntry, Files() As FTPEntry) it works fine Now I made a mistake, entered the wrong FTP address In this case, Success is false and i call: Code: Copy CallSubDelayed3(Target,"FTP_Backup_Fin",3,LastException) The "Target" for LastException is a String Variable. Code: Copy Wait For FTP_Backup_Fin(SuccessCode as Byte, Error as String) there crashes the app (with the wrong FTP Server, other errors view o.k.) LastException is: (GaiException) android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname) and Crash with: java.lang.ClassCastException: anywheresoftware.b4a.objects.B4AException cannot be cast to java.lang.String why the LastException cant cast to string??
Hi, with this Code i get a List from the FTP Server: Code: Copy FTP.Initialize("FTP",server,port,user,passwort) 'server,port,user,passwort-> string variable FTP.PassiveMode=True FTP.List("/") Wait For FTP_ListCompleted (ServerPath As String, Success As Boolean, FolderS() As FTPEntry, Files() As FTPEntry) it works fine Now I made a mistake, entered the wrong FTP address In this case, Success is false and i call: Code: Copy CallSubDelayed3(Target,"FTP_Backup_Fin",3,LastException) The "Target" for LastException is a String Variable. Code: Copy Wait For FTP_Backup_Fin(SuccessCode as Byte, Error as String) there crashes the app (with the wrong FTP Server, other errors view o.k.) LastException is: (GaiException) android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname) and Crash with: java.lang.ClassCastException: anywheresoftware.b4a.objects.B4AException cannot be cast to java.lang.String why the LastException cant cast to string??
DonManfred Expert Licensed User Longtime User Sep 5, 2019 #2 Exceptions cannot be cast to a string. Change your sub signature of FTP_Backup_Fin to get an OBJECT as last parameter. Last edited: Sep 5, 2019 Upvote 0
Exceptions cannot be cast to a string. Change your sub signature of FTP_Backup_Fin to get an OBJECT as last parameter.
Erel B4X founder Staff member Licensed User Longtime User Sep 5, 2019 #3 In the case of "wrapper" objects the target type with CallSub calls must be exact. Change it to: Code: Copy Wait For FTP_Backup_Fin(SuccessCode as Byte, Error as Exception) Upvote 0
In the case of "wrapper" objects the target type with CallSub calls must be exact. Change it to: Code: Copy Wait For FTP_Backup_Fin(SuccessCode as Byte, Error as Exception)
M mw71 Well-Known Member Licensed User Longtime User Sep 5, 2019 #4 thanks, especially Erel. When changing to Exception I have seen in the Help (Tooltip) that there (Last)Exception.Message. This works fine. Upvote 0
thanks, especially Erel. When changing to Exception I have seen in the Help (Tooltip) that there (Last)Exception.Message. This works fine.