From 96077ce7e6125cdba959925d0a2b7b1f8ee54046 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Fri, 22 Nov 2013 13:32:52 +0100 Subject: Do not throw exception for normal code flow (exceptions::no_such_field). --- src/plainTextPart.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'src/plainTextPart.cpp') diff --git a/src/plainTextPart.cpp b/src/plainTextPart.cpp index e1959af1..bdb76c4d 100644 --- a/src/plainTextPart.cpp +++ b/src/plainTextPart.cpp @@ -75,20 +75,23 @@ void plainTextPart::parse(shared_ptr /* message */, { m_text = vmime::clone(textPart->getBody()->getContents()); - try - { - const contentTypeField& ctf = - *textPart->getHeader()->findField (fields::CONTENT_TYPE); + shared_ptr ctf = + textPart->getHeader()->findField (fields::CONTENT_TYPE); - m_charset = ctf.getCharset(); - } - catch (exceptions::no_such_field&) + if (ctf) { - // No "Content-type" field. + try + { + m_charset = ctf->getCharset(); + } + catch (exceptions::no_such_parameter&) + { + // No "charset" parameter. + } } - catch (exceptions::no_such_parameter&) + else { - // No "charset" parameter. + // No "Content-type" field. } } -- cgit v1.2.3