Misplaced except in line 12?
Within except there is handling of ResponseStatusCode = 200, which means successful receiving.
Yes and no. The except block is there on purpose.
What i did not explicitly mentioned to J-G (expected to do some homework
) is that the except block should handle the exceptions that J-G wants to catch there.
That is why in one of my examples _shows_ which exact exception occurs.
An except block act similar like a case statement:
except
on E: Exception do // This will catch _all_ exceptions also those specific to THTTPClient
begin
end
on E: Otherexception do
begin
end
else // what to do when none of the above cases matched the specific exception and we're stuck here ? e.g. all so far unhandled exceptions
begin
end;
So, in case you wish to 'catch' a httpclient specific exception you would have to add that to the exception case list
And fwiw you need to check ResponseStatusCode if you wish to make sure that the request was handled ok as there are other errors that do not raise an exception (or can be 'removed' from the exception list).
So, depending on how you handle the exception J-G could move that code after the exception handler.
edit:
some reading material on exceptions
here and
here.
fwiw: You should 'catch' EHTTPClient exception, and decide what you wish to do with it, e.g. silently ignore, handle, or (re)raise.