Dear enlighted ones.
I happen to try to finsh a kind of a function library that my Main program can utilize.
As of now, Everything work great... but. I would like to implement some kind of error handling.
The way I do this also work, but the error is generated so that the procedure detecting the error is listed when Delphi breaks execution.
Is there some way of implementing something so that the Break shows the line in main program instead?
It is important to me to make descriptive error messages that can be used to solve problem.
//From Main program PROCEDURE TestForError; BEGIN Example(6); Example(8); Example(10); Example(15); // I would like Delphi to break here, and show a nice red line. Example(7); Example(1); END; //From Library Unit PROCEDURE Example(Max10:BYTE); VAR ErrorMessage:STRING; BEGIN IF Max10>10 THEN BEGIN ErrorMessage='An error occurred. Parameter can not hold larger values than 10'; RAISE Exception.Create(ErrorMessage) at @Example; END; END;
I thought I could use something like this, but I need some kind of more information.
This way of raising an exception does everything I would like, except it show my LibraryUnit and procedure there as the cause of the error. This is of course correct enough as it is there the error is detected. I would just like to redirect the error so that the line calling the procedure get the "fault", hence Delphi breaks, showing this line of code instead of showing my procedure in library unit.
Also, what if many procedures in my library is used in order to determine that there is an error. I would still like only the line in Main program to be shown as red after Delphi break execution.
Many thanks in advance for any help regarding this issue.:)