History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: IDEA-16557
Type: Bug Bug
Status: Open Open
Assignee: Unassigned
Reporter: Serge Baranov
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
IDEA: Feedback

Add Catch Clause works, but wrong order

Created: 29 Nov 07 13:12   Updated: 29 Nov 07 13:12
Component/s: Editor. Intention Actions

Build: 7,576
Severity: Medium


 Description  « Hide
Support feedback:

In the code below, I ask it to add the catch clause for the line that says "msg.setFrom(new InternetAddress(...". It adds the correct catch clauses,
but in the wrong order.

public static void main(String[] args) {
  try {
    String to;
    Properties props = new Properties();
    props.put("mail.smtp.host", "mail.climbingvine.ca");
    //set the email session debug to false
    Session session = Session.getDefaultInstance(props, null);
    session.setDebug(false);

    //Create a message
    MimeMessage msg = new MimeMessage(session);
    //Set the setFrom
    msg.setFrom(new InternetAddress("support@climbingvine.ca"));
    //Set the to Field
    to = "web_directory@somewhere.com";

    if (to == null) {
      return;
    }
    InternetAddress[] address = {new InternetAddress(to)};
    //set the to field in the email address
    msg.setRecipients(Message.RecipientType.TO, address);
    //Set the subject and dates
    msg.setSubject("Graduate Application Notification");
    msg.setSentDate(new Date());
    MimeBodyPart mbp1 = new MimeBodyPart();
    //Create the message body
    body = createMessageBody(req, res);
    mbp1.setText(body);
    Multipart mp = new MimeMultipart();
    mp.addBodyPart(mbp1);

    msg.setContent(mp);
    //send the email message
    Transport.send(msg);
  }
}

Results in:

} catch (MessagingException e) {
    e.printStackTrace();
  } catch (AddressException e) {
    e.printStackTrace();
  }

Expected result:

} catch (AddressException e) {
    e.printStackTrace();
  } catch (MessagingException e) {
    e.printStackTrace();
  }


 All   Comments   Work Log   Change History      Sort Order:
There are no comments yet on this issue.