How to get query text from EMSError
Posted: Fri  28 Jun 2013 09:11
				
				Hello,
I'm trying to protocol exceptions in my app and want to include the whole query text, when the error is EMSError.
I can do following
works fine, if the query is placed on form, datamodule etc. But if the query is just ad-hoc, like
the field EMSError.Component is empty.
I understand, that is has to be empty, as the component is already freed, when the global exception handler comes to action.
But - is there some way to extend the EMSError class to include the query text as a string attribute, so that also in such cases the global exception handler can get the text, even when the query is already destroyed?
Thanks for info,
Ludek.
			I'm trying to protocol exceptions in my app and want to include the whole query text, when the error is EMSError.
I can do following
Code: Select all
e: EMSError;
begin
  if e.Component is TMSQuery then ... TMSQuery(e.Component).sql.text ...
Code: Select all
  q: TMSQuery;
begin
  q := TMSQuery.Create;
  try
    ...
    q.execsql
  finally
    q.free;
  end;
I understand, that is has to be empty, as the component is already freed, when the global exception handler comes to action.
But - is there some way to extend the EMSError class to include the query text as a string attribute, so that also in such cases the global exception handler can get the text, even when the query is already destroyed?
Thanks for info,
Ludek.