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

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top