I originally asked about this question on another platform (here).
In Inno Setup it has the following message definition:
ErrorFileHash2=Invalid file hash: expected %1, found %2
This message is displayed when the installer tries to download and run a file with the wrong hash value.
In my script I have:
function NextButtonClick(CurPageID: integer): boolean;
begin
Result := True;
if (CurPageID = wpSelectTasks) then
begin
DownloadPage.Clear;
if (WizardIsTaskSelected('downloadhelp')) then
AddFileForDownload('{#HelpDocSetupURL}', 'HelpDocSetup.exe',
'{#GetSHA256OfFile("..\HelpNDoc\CHM\Output\MSAHelpDocumentationSetup.exe")}');
end
else
if (CurPageID = wpReady) then
begin
DownloadPage.Show;
try
try
DownloadPage.Download;
Result := True;
except
SuppressibleMsgBox(
AddPeriod(GetExceptionMessage), mbCriticalError, MB_OK, IDOK);
Result := False;
end;
finally
DownloadPage.Hide;
end;
end;
end;
The error message that is displayed when there is an issue is rather ugly. The following was suggested to me:
It only shows a message box if you don't handle the exception. Use try/except and then you can do things like re-raising the exception with a filename added or using a task dialog.
I thought I would try the message box designer:
Which creates the following code:
// Display a message box
SuppressibleTaskDialogMsgBox(
'Unable to download [file]', 'This is because the checksum value does not match',
mbError, MB_OK, ['OK'], 0, IDOK);
But I don't know what I am doing here.
- How do I handle the exception that displays this error?
- How do I show a better task dialog? Once that also includes the has details and file name?