Autor Beitrag
stiftmaster
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 149



BeitragVerfasst: Sa 15.07.06 23:55 
Hallo,

ich setze TIdHTTP zum Aufrufen des einer html-Datei im Internet ein. Es kann vorkommen, dass aber gar keine Internetverbindung bestelt. Dies soll dann dem Benutzer angezeigt werden. Meine Idee:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
procedure ShowPage();
var
  Indy: TIdHTTP;
  Text: string;
begin
  Indy := TIdHTTP.Create(nil);
  Indy.AllowCookies := False;
  try
    Text := Indy.Get(Url);
  except
    InfoLabel.Text := 'Fehler...';
  end;
end;


Komischerweise schmeißt Indy schon eine Fehlermeldung die anzeigt wird bevor es in den except-Teil wandert - Will ich aber nicht. Will das Fehlerhandling ja selber verwalten. Hat jemand eine Idee, wieso das mit try-except nicht klappt. Dankend

Stefan


Zuletzt bearbeitet von stiftmaster am So 16.07.06 00:04, insgesamt 1-mal bearbeitet
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Sa 15.07.06 23:57 
Moin!

Lass das Programm mal ohne die IDE laufen. Wir dann immernoch eine Exception angezeigt?

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
stiftmaster Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 149



BeitragVerfasst: So 16.07.06 00:03 
Hi,

thx für deine Antwort - was genau meinst du mit "ohne IDE laufen lassen"? Ohne Entwicklungsumgebung und direkt über den Explorer starten => kommt die gleiche Fehlermeldung.

Stefan
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: So 16.07.06 00:05 
Moin!

Ja, genau das meinte ich. ;)

Wenn es dann noch einen vertretbaren Aufwand für dich darstellt, uns zu verraten WELCHE FEHLERMELDUNG da ausgegeben wird... :roll: ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
stiftmaster Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 149



BeitragVerfasst: So 16.07.06 00:09 
Die Kiste, auf der ich den Code hab, steht grad leider nicht neben mir. Meine aber dass wenn ich das Netzwerkkabel nicht drin habe, dass dann ein Fehler 10011 oder so ähnlich auftritt (kann ich morgen genau sagen). Möchte aber nicht einen bestimmten Fehler abrufen, sondern alle, die auftreten können und dem Benutzer in einer Fehlermeldung (Label.Caption) ausgeben und nicht in einem Fenster, was ich nicht unter Kontrolle habe :-)

Stefan
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: So 16.07.06 00:17 
Moin!

Dann pack doch mal das Create mit in dem try-Block. ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
stiftmaster Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 149



BeitragVerfasst: So 16.07.06 09:09 
Hi!

Der Fehlercode lautet 11001 (Host nicht gefunden) und wird in IdStack => TIdStack.RaiseSocketError aufgerufen.

Wenn ich das create mit den den try-Block nehme, kommt der gleiche Fehler, aber ich bekomme beim Compilieren korrekterweise eine Warnung angezeigt, dass Indy nicht initialisiert sein muss - daher ist es gleich wieder an die richtige Stelle verschoben worden :-)

Weitere Ideen?

Dankend - Stefan
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: So 16.07.06 23:13 
Moin!

Also, ich habe das hier getestet:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
procedure TForm1.Button1Click(Sender: TObject);
const
  url = 'http://www.google.de1';
var
  Indy: TIdHTTP;
begin
  Indy := TIdHTTP.Create(nil);
  Indy.AllowCookies := False;
  try
    Memo1.Lines.Text := Indy.Get(Url);
  except
    ShowMessage('Fehler');
  end;
  Indy.Free;
end;

Der "Fehler" wird korrekt gefangen; allerdings - wie ich schon angedeutet hatte - nicht in der IDE, da wird natürlich die Ausführung angehalten.

Wenn ich das Programm aber ausserhalb der IDE starte, dann läuft´s korrekt. Du kannst natürlich auch das Stoppen bei Exceptions in der IDE abschalten.

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.