| Description | Hierarchy | Fields | Methods | Properties |
type TCodeBreaker = class(TObject)
TCodeBreaker is a special class intended to be 1. raised and catched (like a normal Exception descendant) 2. but, unlike normal Exception descendant, it's not to be raised to signal some error. Instead it should be used to exit from some code blocks.
When you define some descendant of TCodeBreaker class you must always say when it's catched, and catching it should always look like
try
{ ... some code that can raise BreakXxx ... }
except on BreakXxx do ; end;
This way doing BreakXxx.Create; inside code { ... some code ... } will work like doing Exit but with obvious differences – e.g. procedures called from { ... some code ... } can also raise BreakXxx to exit from the code.
Example – see BreakGLWinEvent in GLWindow unit.
Naming conventions: Break<CodeName> (not BreakFrom<CodeName> or EBreak<CodeName> etc.)
This class does not inherit from Exception because 1. it does not signal some "exceptional" situation 2. it must be always catched and "silenced" in some try ... except block, so having here property like Message: string would be a waste of time and memory.