Good day! I am writing a program for transferring files over a network (TCP protocol) using the components of Indy idTCPServer , idTCPClient . On the client side, I write the following code to receive the file from the server:

 try put:=directorylistbox1.Directory+'\'; IdTCPClient1.ConnectAndGetAll; except // **Обработка исключений.**.. end; 

The question is how you can connect the try..except construct try..except that it distinguishes between various errors when retrieving data:

  1. Server is not responding
  2. File size is too big
  3. There is no file on the server
  4. Is the connection broken before the file is received?

Tell me, what do I need to register in exception handling?

    1 answer 1

    See help

     try ... except on E:EZeroDivide do HandleZeroDivide(E); on E:EOverflow do HandleOverflow(E); on E:EMathError do HandleMathError(E); end; 

    The corresponding exception for indy should be an error code.

    UPD added an exception variable to the code that will contain information about the exception (E.message, etc.).

    • EZeroDivide, EOverflow, EMathError from where are taken, what exactly do they process? Where can I see a list of possible exceptions for my case? - IntegralAL
    • one
      There is an IdException.pas file that describes all possible exceptions. There is brief information about indy about them. There are many, yes. Naturally, not all of them can occur, so you can look at the code for a specific method, in the help, too, they write about some exceptions. By the way, not all your situations can cause exceptions, there is still no universal method - what situations you need to handle, respectively, and diagnose them, block other exceptions through the base Exception class, log. - Yura Ivanov