You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my case(D11.1), Imaging.UpdateExceptMessage() updates current exception E (normally get from GetException()) then E will be re-raised. But this causes the caller unable to catch the exception again since RTL will free the old exception after the raise.
try
Format.SaveToFile(FileName, DataArray, False); // eg: Access denied
except
on e: Exception do
... ShowErrMsg(e.Message); // e is actually invalid and causes errors later
//Project xxx.exe raised exception class EInvalidPointer with message 'Invalid pointer operation'.
//Access violation at address 0040BB30 in module 'xxx'. Read of address 00000000.
end;
I temporarily altered the code like this to make it work:
The text was updated successfully, but these errors were encountered:
avpnvpn
changed the title
caller can not get exception after raise UpdateExceptMessage()
Caller can not get exception after raising UpdateExceptMessage()
Jul 1, 2022
In my case(D11.1), Imaging.UpdateExceptMessage() updates current exception E (normally get from GetException()) then E will be re-raised. But this causes the caller unable to catch the exception again since RTL will free the old exception after the raise.
try
Format.SaveToFile(FileName, DataArray, False); // eg: Access denied
except
on e: Exception do
... ShowErrMsg(e.Message); // e is actually invalid and causes errors later
//Project xxx.exe raised exception class EInvalidPointer with message 'Invalid pointer operation'.
//Access violation at address 0040BB30 in module 'xxx'. Read of address 00000000.
end;
I temporarily altered the code like this to make it work:
function UpdateExceptMessage(E: Exception; const MsgToPrepend: string; const Args: array of const): Exception;
begin
//Result := E;
//E.Message := Format(MsgToPrepend, Args) + ' ' + SExceptMsg + ': ' + E.Message;
Result := EImagingError.Create(Format(MsgToPrepend, Args) + ' ' + SExceptMsg + ': ' + E.Message);
end;
Thanks.
The text was updated successfully, but these errors were encountered: