aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2014-02-23 14:34:35 +0000
committerVincent Richard <[email protected]>2014-02-23 14:34:35 +0000
commit0b03b3267cc13f334222a2fe3230acc2bdb3f4fe (patch)
treeabaa87be66e31c95c2c50e3b7eaad41d7af5f7fc
parentFixed documentation. (diff)
downloadvmime-0b03b3267cc13f334222a2fe3230acc2bdb3f4fe.tar.gz
vmime-0b03b3267cc13f334222a2fe3230acc2bdb3f4fe.zip
Make serviceFactory::create throw instead of dying for invalid protocols.
-rw-r--r--src/vmime/net/serviceFactory.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/vmime/net/serviceFactory.cpp b/src/vmime/net/serviceFactory.cpp
index bbc9944a..b6f90eb2 100644
--- a/src/vmime/net/serviceFactory.cpp
+++ b/src/vmime/net/serviceFactory.cpp
@@ -60,7 +60,12 @@ shared_ptr <service> serviceFactory::create
(shared_ptr <session> sess, const string& protocol,
shared_ptr <security::authenticator> auth)
{
- return (getServiceByProtocol(protocol)->create(sess, auth));
+ shared_ptr <const registeredService> rserv = getServiceByProtocol(protocol);
+
+ if (!rserv)
+ throw exceptions::no_factory_available("No service is registered for protocol '" + protocol + "'.");
+
+ return rserv->create(sess, auth);
}