Error hiding
Appearance
![]() | This article provides insufficient context for those unfamiliar with the subject. |
Error hiding is a common practice to hide error messages by overriding them with exception handling. The user will never know what realy went wrong.
Example:
try ImportFile(filename); except // a exception with almost no information raise Exception.Create('import failed'); end;
// better approach try ImportFile(filename); except on E:Exception do begin // build a informative message E.Message := 'Import of file <'+filename+'> failed.'+#13#10 + E.Message; // re-raise the exception raise; end; end;