From 0b03b3267cc13f334222a2fe3230acc2bdb3f4fe Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Sun, 23 Feb 2014 15:34:35 +0100 Subject: [PATCH] Make serviceFactory::create throw instead of dying for invalid protocols. --- src/vmime/net/serviceFactory.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 serviceFactory::create (shared_ptr sess, const string& protocol, shared_ptr auth) { - return (getServiceByProtocol(protocol)->create(sess, auth)); + shared_ptr rserv = getServiceByProtocol(protocol); + + if (!rserv) + throw exceptions::no_factory_available("No service is registered for protocol '" + protocol + "'."); + + return rserv->create(sess, auth); }