Answers for "try and catch"

21

java try catch

try {
  // Code that may have error
} catch(ErrorName e){
  // Another code
}
Posted by: Guest on November-26-2019
29

javascript try catch

var someNumber = 1;
try {
  someNumber.replace("-",""); //You can't replace a int
} catch(err) {
 console.log(err);
}
Posted by: Guest on June-27-2019
6

try block in java

try {
  //  Block of code to try
}
catch(Exception e) {
  //  Block of code to handle errors
}
Posted by: Guest on May-02-2020
0

try and catch

try
            {
                MailMessage mail = new MailMessage();
                SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");

                mail.From = new MailAddress("[email protected]");
                mail.To.Add("to_address");
                mail.Subject = "Test Mail";
                mail.Body = "This is for testing SMTP mail from GMAIL";

                SmtpServer.Port = 587;
                SmtpServer.Credentials = new System.Net.NetworkCredential("username", "password");
                SmtpServer.EnableSsl = true;

                SmtpServer.Send(mail);
                MessageBox.Show("mail Send");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
Posted by: Guest on August-28-2021

Browse Popular Code Answers by Language