Question

In Delphi, I have a hierarchy of routines. Routine 'A' calls 'B' which calls 'C' which calls 'D'. 'D' does some checking, and it encounters an error of some type, maybe an Exception,maybe just a logical error. Regardless, when 'D' encounters the error, is there anyway for control to pass back to 'A' without having 'D' return a 'failure' code, which 'C' checks for, which returns a failure code, which 'B' checks for, etc...?

Thanks

GS

Was it helpful?

Solution

There are exactly two ways to do what you want:

  1. Return an error/status code and have every function on the call stack check that code.
  2. Raise an exception and handle it at the high level.

You do not wish to use option 1, so that leaves option 2.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top