diff options
| author | Vincent Richard <[email protected]> | 2013-11-22 13:32:52 +0100 |
|---|---|---|
| committer | Vincent Richard <[email protected]> | 2013-11-22 13:32:52 +0100 |
| commit | 96077ce7e6125cdba959925d0a2b7b1f8ee54046 (patch) | |
| tree | aa478ebd974ce101e8e16d9c6cbab32643725a31 /src/net | |
| parent | Do not throw exception for normal code flow. (diff) | |
| download | vmime-96077ce7e6125cdba959925d0a2b7b1f8ee54046.tar.gz vmime-96077ce7e6125cdba959925d0a2b7b1f8ee54046.zip | |
Do not throw exception for normal code flow (exceptions::no_such_field).
Diffstat (limited to 'src/net')
| -rw-r--r-- | src/net/transport.cpp | 68 |
1 files changed, 26 insertions, 42 deletions
diff --git a/src/net/transport.cpp b/src/net/transport.cpp index eae4a024..dd7281d0 100644 --- a/src/net/transport.cpp +++ b/src/net/transport.cpp @@ -125,64 +125,48 @@ static void extractMailboxes void transport::send(shared_ptr <vmime::message> msg, utility::progressListener* progress) { // Extract expeditor - mailbox expeditor; + shared_ptr <mailbox> fromMbox = + msg->getHeader()->findFieldValue <mailbox>(fields::FROM); - try - { - const mailbox& mbox = - *msg->getHeader()->findField(fields::FROM)->getValue <mailbox>(); - - expeditor = mbox; - } - catch (exceptions::no_such_field&) - { + if (!fromMbox) throw exceptions::no_expeditor(); - } + + mailbox expeditor = *fromMbox; // Extract sender - mailbox sender; + shared_ptr <mailbox> senderMbox = + msg->getHeader()->findFieldValue <mailbox>(fields::SENDER); - try - { - const mailbox& mbox = - *msg->getHeader()->findField(fields::SENDER)->getValue <mailbox>(); + mailbox sender; - sender = mbox; - } - catch (exceptions::no_such_field&) - { + if (!senderMbox) sender = expeditor; - } + else + sender = *senderMbox; // Extract recipients mailboxList recipients; - try - { - const addressList& to = - *msg->getHeader()->findField(fields::TO)->getValue <addressList>(); + // -- "To" field + shared_ptr <addressList> addresses = + msg->getHeader()->findFieldValue <addressList>(fields::TO); - extractMailboxes(recipients, to); - } - catch (exceptions::no_such_field&) { } + if (addresses) + extractMailboxes(recipients, *addresses); - try - { - const addressList& cc = - *msg->getHeader()->findField(fields::CC)->getValue <addressList>(); + // -- "Cc" field + addresses = + msg->getHeader()->findFieldValue <addressList>(fields::CC); - extractMailboxes(recipients, cc); - } - catch (exceptions::no_such_field&) { } + if (addresses) + extractMailboxes(recipients, *addresses); - try - { - const addressList& bcc = - *msg->getHeader()->findField(fields::BCC)->getValue <addressList>(); + // -- "Bcc" field + addresses = + msg->getHeader()->findFieldValue <addressList>(fields::BCC); - extractMailboxes(recipients, bcc); - } - catch (exceptions::no_such_field&) { } + if (addresses) + extractMailboxes(recipients, *addresses); // Process message header by removing fields that should be removed // before transmitting the message to MSA, and adding missing fields |
