aboutsummaryrefslogtreecommitdiffstats
path: root/src/misc/importanceHelper.cpp
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2013-11-22 12:32:52 +0000
committerVincent Richard <[email protected]>2013-11-22 12:32:52 +0000
commit96077ce7e6125cdba959925d0a2b7b1f8ee54046 (patch)
treeaa478ebd974ce101e8e16d9c6cbab32643725a31 /src/misc/importanceHelper.cpp
parentDo not throw exception for normal code flow. (diff)
downloadvmime-96077ce7e6125cdba959925d0a2b7b1f8ee54046.tar.gz
vmime-96077ce7e6125cdba959925d0a2b7b1f8ee54046.zip
Do not throw exception for normal code flow (exceptions::no_such_field).
Diffstat (limited to 'src/misc/importanceHelper.cpp')
-rw-r--r--src/misc/importanceHelper.cpp34
1 files changed, 12 insertions, 22 deletions
diff --git a/src/misc/importanceHelper.cpp b/src/misc/importanceHelper.cpp
index 8066cc5f..b13f7466 100644
--- a/src/misc/importanceHelper.cpp
+++ b/src/misc/importanceHelper.cpp
@@ -39,25 +39,13 @@ void importanceHelper::resetImportance(shared_ptr <message> msg)
void importanceHelper::resetImportanceHeader(shared_ptr <header> hdr)
{
- try
- {
- shared_ptr <headerField> fld = hdr->findField("X-Priority");
+ shared_ptr <headerField> fld;
+
+ if ((fld = hdr->findField("X-Priority")))
hdr->removeField(fld);
- }
- catch (exceptions::no_such_field)
- {
- // Ignore
- }
- try
- {
- shared_ptr <headerField> fld = hdr->findField("Importance");
+ if ((fld = hdr->findField("Importance")))
hdr->removeField(fld);
- }
- catch (exceptions::no_such_field)
- {
- // Ignore
- }
}
@@ -70,9 +58,10 @@ importanceHelper::Importance importanceHelper::getImportance(shared_ptr <const m
importanceHelper::Importance importanceHelper::getImportanceHeader(shared_ptr <const header> hdr)
{
// Try "X-Priority" field
- try
+ shared_ptr <const headerField> fld = hdr->findField("X-Priority");
+
+ if (fld)
{
- const shared_ptr <const headerField> fld = hdr->findField("X-Priority");
const string value = fld->getValue <text>()->getWholeBuffer();
int n = IMPORTANCE_NORMAL;
@@ -93,12 +82,13 @@ importanceHelper::Importance importanceHelper::getImportanceHeader(shared_ptr <c
return (i);
}
- catch (exceptions::no_such_field)
+ else
{
// Try "Importance" field
- try
+ fld = hdr->findField("Importance");
+
+ if (fld)
{
- const shared_ptr <const headerField> fld = hdr->findField("Importance");
const string value = utility::stringUtils::toLower(utility::stringUtils::trim
(fld->getValue <text>()->getWholeBuffer()));
@@ -109,7 +99,7 @@ importanceHelper::Importance importanceHelper::getImportanceHeader(shared_ptr <c
else
return (IMPORTANCE_NORMAL);
}
- catch (exceptions::no_such_field)
+ else
{
// Default
return (IMPORTANCE_NORMAL);