Runtime Exception in SendSync within Thread

I 'm trying to set up a REST-API connection with a WordPress website within a thread (to be able to show a ProgressWheel). To catch a typo within URL I have the following code - within Run of the Thread:

try
WebConnection.SendSync(“POST”, RequestString, filejson, 30)
catch e as RuntimeException
// “Error in URL” some code to
Var ErrorString As String = e.ErrorNumber.ToString + " " + e.Message
Me.AddUserInterfaceUpdate(“txtWarning”:"Error in URL - " + ErrorString)
Me.Stop
end try

The program crashes on the WebConnection.SendSync when there’s an error in the URL (in the RequestString with a RuntimeException with ErrorNumber 12007 but it is not caught in the Exception handler. What am I doing wrong??

Can you reproduce this is a sample project?

Sounds like a bug, but just to confirm that it’s not due to something your app does.

And then report via Feedback app.

I’ve created a sample project.
The RuntimeException of SendSync is not handled when the URL is incorrect in the RequestString of the HTTP POST request.
It has nothing to do with the Thread (like I mentioned before) - I’ve taken that out of the sample project to keep it simple. The sample is reported via the Feedback app.

I’ve tried a couple of times to provide the feedback. But I keep getting the message:
“Communication with the Feedback master server has failed. Feedback will now quit.”
I will try again later

Edit… you use the SendSync for a folderitem.

Are you sure you can write to the FolderItem or is it already existing?

What message is in the Exception.Message ?

Hi Derk,
Yes the folderitem already exists.
The problem is the application crashes on SendSync when the URL is not correct.
In the debugger I see it has a RuntimeException but it looks like this is not caught in catch clause.

It may be better to first remove the file, it may not overwrite it perhaps?

Again I’ve tried to provide the feedback + sample project. But I keep getting the message:
“Communication with the Feedback master server has failed. Feedback will now quit."
not sure how to proceed…

You should be able to see where the RuntimeException happened. maybe at some other position?
Turn: Project → Break On Exceptions on un the IDE menu.

Sorry I wasn’t clear:
I see the RuntimeException in the debugger:
With the ErrorNumber: 12007
and the ErrorMessage: The server name or address could not be resolved

exactly as what I would expect.
but the application crashes at the SendSync statement

Ah that means the RequestString is invalid. Maybe there is an error in the url or it has the wrong encoding? Most probably a bad character or invalid url string…

Yes that’s true - the RequestString is invalid because there’s a deliberate typo in the URL - which is what I want to catch in the exceptionhandler.

Well you see the debugger exception that means the debugger breaked into the exception if you press the play button (resume |> ) then the project would resume running… If you put:

#pragma BreakOnExceptions False // Would not break the following exception(s) until reset.
try
  WebConnection.SendSync(“POST”, RequestString, filejson, 30)
catch e as RuntimeException
// “Error in URL” some code to
  Var ErrorString As String = e.ErrorNumber.ToString + " " + e.Message
  Me.AddUserInterfaceUpdate(“txtWarning”:"Error in URL - " + ErrorString)
  Me.Stop
end try
#pragma BreakOnExceptions Default // uses the IDE setting again

Ah yes - got it.
Thanks for pointing that out - I forgot about the #pragma

1 Like