Exception handling

uses System.SysUtils;

//any routine may raise an exception:
//there is no "throws" in signatures
procedure MethodWithException;
begin
  raise Exception.Create('test exception');
end;

begin
  try
    MethodWithException;
  except
    on E: Exception do
      WriteLn('Error happened: ', E.Message);
  end;
end.