@@ -152,6 +152,7 @@ TFormTrackerModify = class(TForm)
152152 FTreeNodeRoot: TTreeNode;
153153 FControlerGridTorrentData: TControlerGridTorrentData;
154154
155+ procedure ShowUserErrorMessage (const ErrorText: string; const FormText: string = ' ' );
155156 function TrackerWithURLAndAnnounce (const TrackerURL: UTF8String): boolean;
156157 procedure UpdateTorrent ;
157158 procedure ShowHourGlassCursor (HourGlass: boolean);
@@ -294,8 +295,6 @@ procedure TFormTrackerModify.FormCreate(Sender: TObject);
294295 ConsoleMode;
295296 end ;
296297
297-
298-
299298end ;
300299
301300procedure TFormTrackerModify.FormDestroy (Sender: TObject);
@@ -355,9 +354,7 @@ procedure TFormTrackerModify.MenuItemOnlineCheckSubmitNewTrackonClick(Sender: TO
355354 else
356355 begin
357356 // something is wrong with uploading
358- Application.MessageBox(
359- PChar(' Can not uploading the tracker list' ),
360- ' ' , MB_ICONINFORMATION + MB_OK);
357+ ShowUserErrorMessage(' Can not uploading the tracker list' );
361358 end ;
362359end ;
363360
@@ -403,9 +400,23 @@ procedure TFormTrackerModify.MenuItemOnlineCheckDownloadNewTrackonClick(
403400 if not FDownloadStatus then
404401 begin
405402 // something is wrong with downloading
406- Application.MessageBox(
407- PChar(' Can not downloading the trackers from internet' ),
408- ' ' , MB_ICONINFORMATION + MB_OK);
403+ ShowUserErrorMessage(' Can not downloading the trackers from internet' );
404+ end ;
405+ end ;
406+
407+ procedure TFormTrackerModify.ShowUserErrorMessage (const ErrorText: string;
408+ const FormText: string);
409+ begin
410+ if FConsoleMode then
411+ begin
412+ if FormText = ' ' then
413+ FTrackerList.LogStringList.Add(ErrorText)
414+ else
415+ FTrackerList.LogStringList.Add(FormText + ' : ' + ErrorText);
416+ end
417+ else
418+ begin
419+ Application.MessageBox(PChar(@ErrorText[1 ]), PChar(@FormText[1 ]), MB_ICONERROR);
409420 end ;
410421end ;
411422
@@ -587,15 +598,7 @@ procedure TFormTrackerModify.UpdateTorrent;
587598 // Must have some torrent selected
588599 if (FTrackerList.TorrentFileNameList.Count = 0 ) then
589600 begin
590- if FConsoleMode then
591- begin
592- FTrackerList.LogStringList.Add(' ERROR: No torrent file selected' );
593- end
594- else
595- begin
596- Application.MessageBox(' No torrent file selected' ,
597- ' ' , MB_ICONERROR);
598- end ;
601+ ShowUserErrorMessage(' ERROR: No torrent file selected' );
599602 ShowHourGlassCursor(True);
600603 exit;
601604 end ;
@@ -886,6 +889,7 @@ procedure TFormTrackerModify.ConsoleMode;
886889 else
887890 begin
888891 // failed to load the torrent via folders
892+ ShowUserErrorMessage(' Can not load torrent via folder' );
889893 end ;
890894
891895 end
@@ -916,26 +920,16 @@ procedure TFormTrackerModify.ConsoleMode;
916920 else
917921 begin
918922 // failed to load one torrent
923+ ShowUserErrorMessage(' Can not load torrent file.' );
919924 end ;
920925
921-
922926 finally
923927 StringList.Free;
924928 end ;
925929 end
926930 else
927931 begin // Error. this is not a torrent file
928-
929- if FConsoleMode then
930- begin
931- FTrackerList.LogStringList.Add(' ERROR: No torrent file selected.' );
932- end
933- else
934- begin
935-
936- end ;
937-
938-
932+ ShowUserErrorMessage(' ERROR: No torrent file selected.' );
939933 end ;
940934 end ;
941935 end ;
@@ -1139,17 +1133,8 @@ function TFormTrackerModify.CopyUserInputNewTrackersToList: boolean;
11391133 else
11401134 begin
11411135 // There is error. Show the error.
1142- if FConsoleMode then
1143- begin
1144- FTrackerList.LogStringList.Add(ErrorStr);
1145- end
1146- else
1147- begin
1148- // Show error
1149- Application.MessageBox(PChar(@TrackerStr[1 ]), PChar(@ErrorStr[1 ]), MB_ICONERROR);
1150- end ;
1136+ ShowUserErrorMessage(ErrorStr, TrackerStr);
11511137 end ;
1152-
11531138end ;
11541139
11551140procedure TFormTrackerModify.UpdateTrackerInsideFileList ;
@@ -1575,16 +1560,7 @@ function TFormTrackerModify.AddTorrentFileList(TorrentFileNameStringList:
15751560 // Cancel everything.
15761561 FTrackerList.TorrentFileNameList.Clear;
15771562 FTrackerList.TrackerFromInsideTorrentFilesList.Clear;
1578- if FConsoleMode then
1579- begin
1580- FTrackerList.LogStringList.Add(' Error: Can not read torrent. ' +
1581- TorrentFileNameStr);
1582- end
1583- else
1584- begin
1585- Application.MessageBox(PChar(@TorrentFileNameStr[1 ]),
1586- ' Error: Can not read torrent.' , MB_ICONERROR);
1587- end ;
1563+ ShowUserErrorMessage(' Error: Can not read torrent.' , TorrentFileNameStr);
15881564 Result := False;
15891565 exit;
15901566 end ;
0 commit comments