diff --git a/src/addressList.cpp b/src/addressList.cpp
index 756156d1..15b9227b 100644
--- a/src/addressList.cpp
+++ b/src/addressList.cpp
@@ -151,7 +151,7 @@ void addressList::insertAddressBefore(shared_ptr
beforeAddress, shared
(m_list.begin(), m_list.end(), beforeAddress);
if (it == m_list.end())
- throw std::out_of_range();
+ throw std::out_of_range("Invalid position");
m_list.insert(it, addr);
}
@@ -160,7 +160,7 @@ void addressList::insertAddressBefore(shared_ptr beforeAddress, shared
void addressList::insertAddressBefore(const size_t pos, shared_ptr addr)
{
if (pos >= m_list.size())
- throw std::out_of_range();
+ throw std::out_of_range("Invalid position");
m_list.insert(m_list.begin() + pos, addr);
}
@@ -172,7 +172,7 @@ void addressList::insertAddressAfter(shared_ptr afterAddress, shared_p
(m_list.begin(), m_list.end(), afterAddress);
if (it == m_list.end())
- throw std::out_of_range();
+ throw std::out_of_range("Invalid position");
m_list.insert(it + 1, addr);
}
@@ -181,7 +181,7 @@ void addressList::insertAddressAfter(shared_ptr afterAddress, shared_p
void addressList::insertAddressAfter(const size_t pos, shared_ptr addr)
{
if (pos >= m_list.size())
- throw std::out_of_range();
+ throw std::out_of_range("Invalid position");
m_list.insert(m_list.begin() + pos + 1, addr);
}
@@ -193,7 +193,7 @@ void addressList::removeAddress(shared_ptr addr)
(m_list.begin(), m_list.end(), addr);
if (it == m_list.end())
- throw std::out_of_range();
+ throw std::out_of_range("Invalid position");
m_list.erase(it);
}
@@ -202,7 +202,7 @@ void addressList::removeAddress(shared_ptr addr)
void addressList::removeAddress(const size_t pos)
{
if (pos >= m_list.size())
- throw std::out_of_range();
+ throw std::out_of_range("Invalid position");
const std::vector >::iterator it = m_list.begin() + pos;
diff --git a/src/exception.cpp b/src/exception.cpp
index 45f672a3..042ac4f4 100644
--- a/src/exception.cpp
+++ b/src/exception.cpp
@@ -142,18 +142,6 @@ exception* no_digest_algorithm_available::clone() const { return new no_digest_a
const char* no_digest_algorithm_available::name() const throw() { return "no_digest_algorithm_available"; }
-//
-// no_such_parameter
-//
-
-no_such_parameter::~no_such_parameter() throw() {}
-no_such_parameter::no_such_parameter(const string& name, const exception& other)
- : exception(string("Parameter not found: '") + name + string("'."), other) {}
-
-exception* no_such_parameter::clone() const { return new no_such_parameter(*this); }
-const char* no_such_parameter::name() const throw() { return "no_such_parameter"; }
-
-
//
// no_such_field
//
diff --git a/src/mailboxGroup.cpp b/src/mailboxGroup.cpp
index d4bbb7db..0245affb 100644
--- a/src/mailboxGroup.cpp
+++ b/src/mailboxGroup.cpp
@@ -258,7 +258,7 @@ void mailboxGroup::insertMailboxBefore(shared_ptr beforeMailbox, share
(m_list.begin(), m_list.end(), beforeMailbox);
if (it == m_list.end())
- throw std::out_of_range();
+ throw std::out_of_range("Invalid position");
m_list.insert(it, mbox);
}
@@ -267,7 +267,7 @@ void mailboxGroup::insertMailboxBefore(shared_ptr beforeMailbox, share
void mailboxGroup::insertMailboxBefore(const size_t pos, shared_ptr mbox)
{
if (pos >= m_list.size())
- throw std::out_of_range();
+ throw std::out_of_range("Invalid position");
m_list.insert(m_list.begin() + pos, mbox);
}
@@ -279,7 +279,7 @@ void mailboxGroup::insertMailboxAfter(shared_ptr afterMailbox, shared_
(m_list.begin(), m_list.end(), afterMailbox);
if (it == m_list.end())
- throw std::out_of_range();
+ throw std::out_of_range("Invalid position");
m_list.insert(it + 1, mbox);
}
@@ -288,7 +288,7 @@ void mailboxGroup::insertMailboxAfter(shared_ptr afterMailbox, shared_
void mailboxGroup::insertMailboxAfter(const size_t pos, shared_ptr mbox)
{
if (pos >= m_list.size())
- throw std::out_of_range();
+ throw std::out_of_range("Invalid position");
m_list.insert(m_list.begin() + pos + 1, mbox);
}
@@ -300,7 +300,7 @@ void mailboxGroup::removeMailbox(shared_ptr mbox)
(m_list.begin(), m_list.end(), mbox);
if (it == m_list.end())
- throw std::out_of_range();
+ throw std::out_of_range("Invalid position");
m_list.erase(it);
}
@@ -309,7 +309,7 @@ void mailboxGroup::removeMailbox(shared_ptr mbox)
void mailboxGroup::removeMailbox(const size_t pos)
{
if (pos >= m_list.size())
- throw std::out_of_range();
+ throw std::out_of_range("Invalid position");
const std::vector >::iterator it = m_list.begin() + pos;
diff --git a/src/parameterizedHeaderField.cpp b/src/parameterizedHeaderField.cpp
index 19a0502a..95421b3f 100644
--- a/src/parameterizedHeaderField.cpp
+++ b/src/parameterizedHeaderField.cpp
@@ -454,7 +454,7 @@ void parameterizedHeaderField::insertParameterBefore(shared_ptr befo
(m_params.begin(), m_params.end(), beforeParam);
if (it == m_params.end())
- throw exceptions::no_such_parameter(beforeParam->getName());
+ throw std::out_of_range("Invalid position");
m_params.insert(it, param);
}
@@ -462,6 +462,9 @@ void parameterizedHeaderField::insertParameterBefore(shared_ptr befo
void parameterizedHeaderField::insertParameterBefore(const size_t pos, shared_ptr param)
{
+ if (pos >= m_params.size())
+ throw std::out_of_range("Invalid position");
+
m_params.insert(m_params.begin() + pos, param);
}
@@ -472,7 +475,7 @@ void parameterizedHeaderField::insertParameterAfter(shared_ptr after
(m_params.begin(), m_params.end(), afterParam);
if (it == m_params.end())
- throw exceptions::no_such_parameter(afterParam->getName());
+ throw std::out_of_range("Invalid position");
m_params.insert(it + 1, param);
}
@@ -480,6 +483,9 @@ void parameterizedHeaderField::insertParameterAfter(shared_ptr after
void parameterizedHeaderField::insertParameterAfter(const size_t pos, shared_ptr param)
{
+ if (pos >= m_params.size())
+ throw std::out_of_range("Invalid position");
+
m_params.insert(m_params.begin() + pos + 1, param);
}
@@ -490,7 +496,7 @@ void parameterizedHeaderField::removeParameter(shared_ptr param)
(m_params.begin(), m_params.end(), param);
if (it == m_params.end())
- throw exceptions::no_such_parameter(param->getName());
+ throw std::out_of_range("Invalid position");
m_params.erase(it);
}
diff --git a/vmime/exception.hpp b/vmime/exception.hpp
index bb59fe8f..e2afcc62 100644
--- a/vmime/exception.hpp
+++ b/vmime/exception.hpp
@@ -152,18 +152,6 @@ public:
};
-class VMIME_EXPORT no_such_parameter : public vmime::exception
-{
-public:
-
- no_such_parameter(const string& name, const exception& other = NO_EXCEPTION);
- ~no_such_parameter() throw();
-
- exception* clone() const;
- const char* name() const throw();
-};
-
-
class VMIME_EXPORT no_such_field : public vmime::exception
{
public:
diff --git a/vmime/parameterizedHeaderField.hpp b/vmime/parameterizedHeaderField.hpp
index 78fc3e44..7a8e8b7d 100644
--- a/vmime/parameterizedHeaderField.hpp
+++ b/vmime/parameterizedHeaderField.hpp
@@ -92,7 +92,7 @@ public:
*
* @param beforeParam parameter before which the new parameter will be inserted
* @param param parameter to insert
- * @throw exceptions::no_such_parameter if the parameter is not in the list
+ * @throw std::out_of_range if the parameter is not in the list
*/
void insertParameterBefore(shared_ptr beforeParam, shared_ptr param);
@@ -101,6 +101,7 @@ public:
* @param pos position at which to insert the new parameter (0 to insert at
* the beginning of the list)
* @param param parameter to insert
+ * @throw std::out_of_range if the position is out of range
*/
void insertParameterBefore(const size_t pos, shared_ptr param);
@@ -108,7 +109,7 @@ public:
*
* @param afterParam parameter after which the new parameter will be inserted
* @param param parameter to insert
- * @throw exceptions::no_such_parameter if the parameter is not in the list
+ * @throw std::out_of_range if the parameter is not in the list
*/
void insertParameterAfter(shared_ptr afterParam, shared_ptr param);
@@ -116,13 +117,14 @@ public:
*
* @param pos position of the parameter before the new parameter
* @param param parameter to insert
+ * @throw std::out_of_range if the position is out of range
*/
void insertParameterAfter(const size_t pos, shared_ptr param);
/** Remove the specified parameter from the list.
*
* @param param parameter to remove
- * @throw exceptions::no_such_parameter if the parameter is not in the list
+ * @throw std::out_of_range if the parameter is not in the list
*/
void removeParameter(shared_ptr param);