Do not throw exception for normal code flow.
This commit is contained in:
parent
f974987070
commit
b075256d8d
@ -428,20 +428,6 @@ exception* unsupported_option::clone() const { return new unsupported_option(*th
|
||||
const char* unsupported_option::name() const throw() { return "unsupported_option"; }
|
||||
|
||||
|
||||
//
|
||||
// no_service_available
|
||||
//
|
||||
|
||||
no_service_available::~no_service_available() throw() {}
|
||||
no_service_available::no_service_available(const string& proto, const exception& other)
|
||||
: net_exception(proto.empty()
|
||||
? "No service available for this protocol."
|
||||
: "No service available for this protocol: '" + proto + "'.", other) {}
|
||||
|
||||
exception* no_service_available::clone() const { return new no_service_available(*this); }
|
||||
const char* no_service_available::name() const throw() { return "no_service_available"; }
|
||||
|
||||
|
||||
//
|
||||
// illegal_state
|
||||
//
|
||||
|
@ -101,7 +101,7 @@ shared_ptr <const serviceFactory::registeredService> serviceFactory::getServiceB
|
||||
return (*it);
|
||||
}
|
||||
|
||||
throw exceptions::no_service_available(name);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
@ -74,8 +74,8 @@ shared_ptr <transport> session::getTransport
|
||||
shared_ptr <session> sess(dynamicCast <session>(shared_from_this()));
|
||||
shared_ptr <service> sv = serviceFactory::getInstance()->create(sess, protocol, auth);
|
||||
|
||||
if (sv->getType() != service::TYPE_TRANSPORT)
|
||||
throw exceptions::no_service_available();
|
||||
if (!sv || sv->getType() != service::TYPE_TRANSPORT)
|
||||
return null;
|
||||
|
||||
return dynamicCast <transport>(sv);
|
||||
}
|
||||
@ -87,8 +87,8 @@ shared_ptr <transport> session::getTransport
|
||||
shared_ptr <session> sess(dynamicCast <session>(shared_from_this()));
|
||||
shared_ptr <service> sv = serviceFactory::getInstance()->create(sess, url, auth);
|
||||
|
||||
if (sv->getType() != service::TYPE_TRANSPORT)
|
||||
throw exceptions::no_service_available();
|
||||
if (!sv || sv->getType() != service::TYPE_TRANSPORT)
|
||||
return null;
|
||||
|
||||
return dynamicCast <transport>(sv);
|
||||
}
|
||||
@ -106,8 +106,8 @@ shared_ptr <store> session::getStore
|
||||
shared_ptr <session> sess(dynamicCast <session>(shared_from_this()));
|
||||
shared_ptr <service> sv = serviceFactory::getInstance()->create(sess, protocol, auth);
|
||||
|
||||
if (sv->getType() != service::TYPE_STORE)
|
||||
throw exceptions::no_service_available();
|
||||
if (!sv || sv->getType() != service::TYPE_STORE)
|
||||
return null;
|
||||
|
||||
return dynamicCast <store>(sv);
|
||||
}
|
||||
@ -119,8 +119,8 @@ shared_ptr <store> session::getStore
|
||||
shared_ptr <session> sess(dynamicCast <session>(shared_from_this()));
|
||||
shared_ptr <service> sv = serviceFactory::getInstance()->create(sess, url, auth);
|
||||
|
||||
if (sv->getType() != service::TYPE_STORE)
|
||||
throw exceptions::no_service_available();
|
||||
if (!sv || sv->getType() != service::TYPE_STORE)
|
||||
return null;
|
||||
|
||||
return dynamicCast <store>(sv);
|
||||
}
|
||||
|
@ -492,21 +492,6 @@ public:
|
||||
};
|
||||
|
||||
|
||||
/** No service available for this protocol.
|
||||
*/
|
||||
|
||||
class VMIME_EXPORT no_service_available : public net_exception
|
||||
{
|
||||
public:
|
||||
|
||||
no_service_available(const string& proto = "", const exception& other = NO_EXCEPTION);
|
||||
~no_service_available() throw();
|
||||
|
||||
exception* clone() const;
|
||||
const char* name() const throw();
|
||||
};
|
||||
|
||||
|
||||
/** The current state of the object does not permit to execute the
|
||||
* operation (for example, you try to close a folder which is not open).
|
||||
*/
|
||||
|
@ -101,9 +101,8 @@ public:
|
||||
* @param sess session
|
||||
* @param protocol protocol name (eg. "pop3")
|
||||
* @param auth authenticator used to provide credentials (can be NULL if not used)
|
||||
* @return a new service instance for the specified protocol
|
||||
* @throw exceptions::no_service_available if no service is registered
|
||||
* for this protocol
|
||||
* @return a new service instance for the specified protocol, or NULL if no service
|
||||
* is registered for this protocol
|
||||
*/
|
||||
shared_ptr <service> create
|
||||
(shared_ptr <session> sess,
|
||||
@ -116,9 +115,8 @@ public:
|
||||
* @param u full URL with at least protocol and server (you can also specify
|
||||
* port, username and password)
|
||||
* @param auth authenticator used to provide credentials (can be NULL if not used)
|
||||
* @return a new service instance for the specified protocol
|
||||
* @throw exceptions::no_service_available if no service is registered
|
||||
* for this protocol
|
||||
* @return a new service instance for the specified protocol or NULL if no service
|
||||
* is registered for this protocol
|
||||
*/
|
||||
shared_ptr <service> create
|
||||
(shared_ptr <session> sess,
|
||||
@ -128,8 +126,7 @@ public:
|
||||
/** Return information about a registered protocol.
|
||||
*
|
||||
* @param protocol protocol name
|
||||
* @return information about this protocol
|
||||
* @throw exceptions::no_service_available if no service is registered
|
||||
* @return information about this protocol, or NULL if no service is registered
|
||||
* for this protocol
|
||||
*/
|
||||
shared_ptr <const registeredService> getServiceByProtocol(const string& protocol) const;
|
||||
|
@ -70,7 +70,8 @@ public:
|
||||
* @param auth authenticator object to use for the new transport service. If
|
||||
* NULL, a default one is used. The default authenticator simply return user
|
||||
* credentials by reading the session properties "auth.username" and "auth.password".
|
||||
* @return a new transport service
|
||||
* @return a new transport service, or NULL if no service is registered for this
|
||||
* protocol or is not a transport protocol
|
||||
*/
|
||||
shared_ptr <transport> getTransport
|
||||
(shared_ptr <security::authenticator> auth = null);
|
||||
@ -81,7 +82,8 @@ public:
|
||||
* @param auth authenticator object to use for the new transport service. If
|
||||
* NULL, a default one is used. The default authenticator simply return user
|
||||
* credentials by reading the session properties "auth.username" and "auth.password".
|
||||
* @return a new transport service
|
||||
* @return a new transport service, or NULL if no service is registered for this
|
||||
* protocol or is not a transport protocol
|
||||
*/
|
||||
shared_ptr <transport> getTransport
|
||||
(const string& protocol,
|
||||
@ -93,7 +95,8 @@ public:
|
||||
* @param auth authenticator object to use for the new transport service. If
|
||||
* NULL, a default one is used. The default authenticator simply return user
|
||||
* credentials by reading the session properties "auth.username" and "auth.password".
|
||||
* @return a new transport service
|
||||
* @return a new transport service, or NULL if no service is registered for this
|
||||
* protocol or is not a transport protocol
|
||||
*/
|
||||
shared_ptr <transport> getTransport
|
||||
(const utility::url& url,
|
||||
@ -107,7 +110,8 @@ public:
|
||||
* @param auth authenticator object to use for the new store service. If
|
||||
* NULL, a default one is used. The default authenticator simply return user
|
||||
* credentials by reading the session properties "auth.username" and "auth.password".
|
||||
* @return a new store service
|
||||
* @return a new store service, or NULL if no service is registered for this
|
||||
* protocol or is not a store protocol
|
||||
*/
|
||||
shared_ptr <store> getStore(shared_ptr <security::authenticator> auth = null);
|
||||
|
||||
@ -117,7 +121,8 @@ public:
|
||||
* @param auth authenticator object to use for the new store service. If
|
||||
* NULL, a default one is used. The default authenticator simply return user
|
||||
* credentials by reading the session properties "auth.username" and "auth.password".
|
||||
* @return a new store service
|
||||
* @return a new store service, or NULL if no service is registered for this
|
||||
* protocol or is not a store protocol
|
||||
*/
|
||||
shared_ptr <store> getStore
|
||||
(const string& protocol,
|
||||
@ -129,7 +134,8 @@ public:
|
||||
* @param auth authenticator object to use for the new store service. If
|
||||
* NULL, a default one is used. The default authenticator simply return user
|
||||
* credentials by reading the session properties "auth.username" and "auth.password".
|
||||
* @return a new store service
|
||||
* @return a new store service, or NULL if no service is registered for this
|
||||
* protocol or is not a store protocol
|
||||
*/
|
||||
shared_ptr <store> getStore
|
||||
(const utility::url& url,
|
||||
|
Loading…
Reference in New Issue
Block a user