Icon View Incident Report

Serious Serious
Reported By: Ralf Mimoun
Reported On: 8/17/2023
For: Version 3.02 Build 8
# 4916 Using an Exit Statement From Within an Except Block Causes Incorrect Application Code Generation

I wrote a server project to implement a simple API: get an ID from a REST call, open the according database table after some parameter health checks, and return the record as Json. Details: EWB 3.02 Build 7 (haven't found anything in the 3.02b8 incidents that might fit), database is DBISAM (but I doubt that this is the culprit).

I added just some lines of code, and it broke in a way I don't understand (see code/comments below).

This is the code that works, cooked down:

    dsFahrauftrag.Params.Values['Fahrauftrag_Nummer'] := IntToStr(FahrauftragNummerAsInt);
    dsFahrauftrag.Open;
    try
      dsFahrauftrag.LoadRows;
      if dsFahrauftrag.RowCount = 0 then begin
        Application.Request.SendError(HTTP_NOT_FOUND, Format('Unknown Entity "%s"', [FahrauftragNummer]));
      end
      else begin
        Application.Request.SendContent('Got it');
      end;
    finally
      dsFahrauftrag.Close;
    end;
  except
    on E2: Exception do begin
      Application.Request.SendError(HTTP_INTERNAL_ERROR, E2.StackTrace + ': ' + E2.Message);
    end;
  end;

Nothing fancy. Now, put a "exit;" right after the first 
"Application.Request.SendError":

...
      if dsFahrauftrag.RowCount = 0 then begin
        Application.Request.SendError(HTTP_NOT_FOUND, Format('Unknown Entity "%s"', [FahrauftragNummer]));
        exit;
      end
...

Then, you get a second resonse from the E2 part, saying

Error 500: Exception instance raised in unit WebData at 2517,4
TDataSet.Close in unit Main at 109,21: Value conversion error

Something goes totally wrong with an exit; in this try/except block, killing the 
.Close method.



Resolution Resolution
Fixed Problem on 8/20/2023 in version 3.02 build 9


Products Affected Products Affected
Elevate Web Builder
Elevate Web Builder Trial

Image