Delphi Compiler Error
E2093 Label ‘%s’ is not declared in current procedure
Reason for the Error & Solution
In contrast to standard Pascal, Borland’s Delphi language does not allow a goto to jump out of the current procedure.
However, his construct is mainly useful for error handling, and the Delphi language provides a more general and structured mechanism to deal with errors: exception handling.
program Produce; label 99; procedure MyProc; begin (*Something goes very wrong...*) goto 99; end; begin MyProc; 99: Writeln('Fatal error'); end.
The example above tries to halt computation by doing a non-local goto.
program Solve; uses SysUtils; procedure MyProc; begin (*Something goes very wrong...*) raise Exception.Create('Fatal error'); end; begin try MyProc; except on E: Exception do Writeln(E.Message); end; end.
In our solution, we used exception handling to stop the program. This has the advantage that we can also pass an error message. Another solution would be to use the standard procedures Halt or RunError.