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 | 3417 (2443) | cekr |
» | Could not create SSL/TLS secure channel. C#Oddelek: Programiranje | 1159 (964) | Looooooka |
» | [ASP.NET] send mailOddelek: Programiranje | 1260 (1197) | Microsoft |
» | Učenje PHP-jaOddelek: Izdelava spletišč | 2733 (2407) | upirna |
» | PHP -> pomočOddelek: Izdelava spletišč | 1177 (1019) | 2nemesis |