Forum » Programiranje » [PHP]try/catch
[PHP]try/catch
Trubadur ::
A mi lahko kdo na kakšnem uporabnem primeru pokaže uporabo try/catch?[:8)]
tnx
tnx
Berite Thomasa!
Spiko ::
ni uporabna, ker je totalno nedelujoča, ampak je pa:
aja pa še za .net je
//poslji mail
try {
var Mail = new MailMessage();
Mail.To = String(UserEmail.Text).Trim();
Mail.From = mailingListOwner;
Mail.Subject = mailingListName + (subscribed ? " unsubscription" : " subscription");
Mail.Body = mailBody;
SmtpMail.Send(Mail);
status.Text += ('
Confirmation e-mail sent to ' + Mail.To);
} catch (ex) {
status.Text = ('Mail not sent to ' + Mail.To + ' because:
' + ex.ToString());
//check the InnerException
while( ex.InnerException != null ) {
status.Text += ("The following InnerException reported: " + ex.InnerException.ToString() );
ex = ex.InnerException;
}
}
Mail = null;
aja pa še za .net je
//poslji mail
try {
var Mail = new MailMessage();
Mail.To = String(UserEmail.Text).Trim();
Mail.From = mailingListOwner;
Mail.Subject = mailingListName + (subscribed ? " unsubscription" : " subscription");
Mail.Body = mailBody;
SmtpMail.Send(Mail);
status.Text += ('
Confirmation e-mail sent to ' + Mail.To);
} catch (ex) {
status.Text = ('Mail not sent to ' + Mail.To + ' because:
' + ex.ToString());
//check the InnerException
while( ex.InnerException != null ) {
status.Text += ("The following InnerException reported: " + ex.InnerException.ToString() );
ex = ex.InnerException;
}
}
Mail = null;
Take that, dirty Linux hippies! Take that, Thieving Macintosh Republicans! XD
Nox ::
zgornja ni ravno v php-ju....
http://www.php.net/manual/en/language.oop5.exceptions.php
function func($i) {
if($i < 10)
echo $i++;
else
throw new Exception();
return $i;
}
for($i = 0;;) {
try {
$i = func($i);
}
catch(Exception $e) {
echo "do konca smo pršl";
break;
}
}
http://www.php.net/manual/en/language.oop5.exceptions.php
...
Vredno ogleda ...
| Tema | Ogledi | Zadnje sporočilo | |
|---|---|---|---|
| Tema | Ogledi | Zadnje sporočilo | |
| » | Visual BasicOddelek: Programiranje | 3682 (2708) | cekr |
| » | Could not create SSL/TLS secure channel. C#Oddelek: Programiranje | 1306 (1111) | Looooooka |
| » | [ASP.NET] send mailOddelek: Programiranje | 1391 (1328) | Microsoft |
| » | Učenje PHP-jaOddelek: Izdelava spletišč | 2992 (2666) | upirna |
| » | PHP -> pomočOddelek: Izdelava spletišč | 1272 (1114) | 2nemesis |