Moved code from 'exception.hpp' to 'exception.cpp' + new features for exceptions.
This commit is contained in:
parent
835cb4a8ed
commit
5c8333cb1e
@ -52,7 +52,7 @@ libvmime_sources = [
|
||||
'encoderQP.cpp', 'encoderQP.hpp',
|
||||
'encoderUUE.cpp', 'encoderUUE.hpp',
|
||||
'encoding.cpp', 'encoding.hpp',
|
||||
'exception.hpp',
|
||||
'exception.cpp', 'exception.hpp',
|
||||
'fileAttachment.cpp', 'fileAttachment.hpp',
|
||||
'genericField.hpp',
|
||||
'genericParameter.hpp',
|
||||
|
621
src/exception.cpp
Normal file
621
src/exception.cpp
Normal file
@ -0,0 +1,621 @@
|
||||
//
|
||||
// VMime library (http://vmime.sourceforge.net)
|
||||
// Copyright (C) 2002-2004 Vincent Richard <vincent@vincent-richard.net>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of
|
||||
// the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
|
||||
#include "exception.hpp"
|
||||
|
||||
|
||||
namespace vmime {
|
||||
|
||||
|
||||
//
|
||||
// exception
|
||||
//
|
||||
|
||||
const exception exception::NO_EXCEPTION;
|
||||
|
||||
|
||||
exception::exception()
|
||||
: m_what(""), m_other(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
exception::exception(const string& what, const exception& other)
|
||||
: m_what(what), m_other(&other != &NO_EXCEPTION ? other.clone() : NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
exception::~exception()
|
||||
{
|
||||
delete (m_other);
|
||||
}
|
||||
|
||||
|
||||
const string exception::what() const throw()
|
||||
{
|
||||
return (m_what);
|
||||
}
|
||||
|
||||
|
||||
const exception* exception::other() const
|
||||
{
|
||||
return (m_other);
|
||||
}
|
||||
|
||||
|
||||
const string exception::name() const
|
||||
{
|
||||
return "exception";
|
||||
}
|
||||
|
||||
|
||||
exception* exception::clone() const
|
||||
{
|
||||
return new exception(*this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
namespace exceptions
|
||||
{
|
||||
|
||||
|
||||
//
|
||||
// bad_field_type
|
||||
//
|
||||
|
||||
bad_field_type::~bad_field_type() throw() {}
|
||||
bad_field_type::bad_field_type(const exception& other)
|
||||
: exception("Bad field type.", other) {}
|
||||
|
||||
exception* bad_field_type::clone() const { return new bad_field_type(*this); }
|
||||
const string bad_field_type::name() const { return "bad_field_type"; }
|
||||
|
||||
|
||||
|
||||
//
|
||||
// charset_conv_error
|
||||
//
|
||||
|
||||
charset_conv_error::~charset_conv_error() throw() {}
|
||||
charset_conv_error::charset_conv_error(const exception& other)
|
||||
: exception("Charset conversion error.", other) {}
|
||||
|
||||
exception* charset_conv_error::clone() const { return new charset_conv_error(*this); }
|
||||
const string charset_conv_error::name() const { return "charset_conv_error"; }
|
||||
|
||||
|
||||
//
|
||||
// no_encoder_available
|
||||
//
|
||||
|
||||
no_encoder_available::~no_encoder_available() throw() {}
|
||||
no_encoder_available::no_encoder_available(const exception& other)
|
||||
: exception("No encoder available.", other) {}
|
||||
|
||||
exception* no_encoder_available::clone() const { return new no_encoder_available(*this); }
|
||||
const string no_encoder_available::name() const { return "no_encoder_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 string no_such_parameter::name() const { return "no_such_parameter"; }
|
||||
|
||||
|
||||
//
|
||||
// no_such_field
|
||||
//
|
||||
|
||||
no_such_field::~no_such_field() throw() {}
|
||||
no_such_field::no_such_field(const exception& other)
|
||||
: exception("Field not found.", other) {}
|
||||
|
||||
exception* no_such_field::clone() const { return new no_such_field(*this); }
|
||||
const string no_such_field::name() const { return "no_such_field"; }
|
||||
|
||||
|
||||
//
|
||||
// no_such_part
|
||||
//
|
||||
|
||||
no_such_part::~no_such_part() throw() {}
|
||||
no_such_part::no_such_part(const exception& other)
|
||||
: exception("Part not found.", other) {}
|
||||
|
||||
exception* no_such_part::clone() const { return new no_such_part(*this); }
|
||||
const string no_such_part::name() const { return "no_such_part"; }
|
||||
|
||||
|
||||
//
|
||||
// no_such_mailbox
|
||||
//
|
||||
|
||||
no_such_mailbox::~no_such_mailbox() throw() {}
|
||||
no_such_mailbox::no_such_mailbox(const exception& other)
|
||||
: exception("Mailbox not found.", other) {}
|
||||
|
||||
exception* no_such_mailbox::clone() const { return new no_such_mailbox(*this); }
|
||||
const string no_such_mailbox::name() const { return "no_such_mailbox"; }
|
||||
|
||||
|
||||
//
|
||||
// no_such_address
|
||||
//
|
||||
|
||||
no_such_address::~no_such_address() throw() {}
|
||||
no_such_address::no_such_address(const exception& other)
|
||||
: exception("Address not found.", other) {}
|
||||
|
||||
exception* no_such_address::clone() const { return new no_such_address(*this); }
|
||||
const string no_such_address::name() const { return "no_such_address"; }
|
||||
|
||||
|
||||
//
|
||||
// open_file_error
|
||||
//
|
||||
|
||||
open_file_error::~open_file_error() throw() {}
|
||||
open_file_error::open_file_error(const exception& other)
|
||||
: exception("Error opening file.", other) {}
|
||||
|
||||
exception* open_file_error::clone() const { return new open_file_error(*this); }
|
||||
const string open_file_error::name() const { return "open_file_error"; }
|
||||
|
||||
|
||||
//
|
||||
// no_factory_available
|
||||
//
|
||||
|
||||
no_factory_available::~no_factory_available() throw() {}
|
||||
no_factory_available::no_factory_available(const exception& other)
|
||||
: exception("No factory available.", other) {}
|
||||
|
||||
exception* no_factory_available::clone() const { return new no_factory_available(*this); }
|
||||
const string no_factory_available::name() const { return "no_factory_available"; }
|
||||
|
||||
|
||||
//
|
||||
// no_platform_dependant_handler
|
||||
//
|
||||
|
||||
no_platform_dependant_handler::~no_platform_dependant_handler() throw() {}
|
||||
no_platform_dependant_handler::no_platform_dependant_handler(const exception& other)
|
||||
: exception("No platform-dependant handler installed.", other) {}
|
||||
|
||||
exception* no_platform_dependant_handler::clone() const { return new no_platform_dependant_handler(*this); }
|
||||
const string no_platform_dependant_handler::name() const { return "no_platform_dependant_handler"; }
|
||||
|
||||
|
||||
//
|
||||
// no_expeditor
|
||||
//
|
||||
|
||||
no_expeditor::~no_expeditor() throw() {}
|
||||
no_expeditor::no_expeditor(const exception& other)
|
||||
: exception("No expeditor specified.", other) {}
|
||||
|
||||
exception* no_expeditor::clone() const { return new no_expeditor(*this); }
|
||||
const string no_expeditor::name() const { return "no_expeditor"; }
|
||||
|
||||
|
||||
//
|
||||
// no_recipient
|
||||
//
|
||||
|
||||
no_recipient::~no_recipient() throw() {}
|
||||
no_recipient::no_recipient(const exception& other)
|
||||
: exception("No recipient specified.", other) {}
|
||||
|
||||
exception* no_recipient::clone() const { return new no_recipient(*this); }
|
||||
const string no_recipient::name() const { return "no_recipient"; }
|
||||
|
||||
|
||||
//
|
||||
// no_object_found
|
||||
//
|
||||
|
||||
no_object_found::~no_object_found() throw() {}
|
||||
no_object_found::no_object_found(const exception& other)
|
||||
: exception("No object found.", other) {}
|
||||
|
||||
exception* no_object_found::clone() const { return new no_object_found(*this); }
|
||||
const string no_object_found::name() const { return "no_object_found"; }
|
||||
|
||||
|
||||
//
|
||||
// no_such_property
|
||||
//
|
||||
|
||||
no_such_property::~no_such_property() throw() {}
|
||||
no_such_property::no_such_property(const string& name, const exception& other)
|
||||
: exception(std::string("No such property: '") + name + string("'."), other) { }
|
||||
|
||||
exception* no_such_property::clone() const { return new no_such_property(*this); }
|
||||
const string no_such_property::name() const { return "no_such_property"; }
|
||||
|
||||
|
||||
//
|
||||
// invalid_property_type
|
||||
//
|
||||
|
||||
invalid_property_type::~invalid_property_type() throw() {}
|
||||
invalid_property_type::invalid_property_type(const exception& other)
|
||||
: exception("Invalid property type.", other) {}
|
||||
|
||||
exception* invalid_property_type::clone() const { return new invalid_property_type(*this); }
|
||||
const string invalid_property_type::name() const { return "invalid_property_type"; }
|
||||
|
||||
|
||||
//
|
||||
// invalid_argument
|
||||
//
|
||||
|
||||
invalid_argument::~invalid_argument() throw() {}
|
||||
invalid_argument::invalid_argument(const exception& other)
|
||||
: exception("Invalid argument.", other) {}
|
||||
|
||||
exception* invalid_argument::clone() const { return new invalid_argument(*this); }
|
||||
const string invalid_argument::name() const { return "invalid_argument"; }
|
||||
|
||||
|
||||
|
||||
#if VMIME_HAVE_MESSAGING_FEATURES
|
||||
|
||||
|
||||
//
|
||||
// messaging_exception
|
||||
//
|
||||
|
||||
messaging_exception::~messaging_exception() throw() {}
|
||||
messaging_exception::messaging_exception(const string& what, const exception& other)
|
||||
: exception(what, other) {}
|
||||
|
||||
exception* messaging_exception::clone() const { return new messaging_exception(*this); }
|
||||
const string messaging_exception::name() const { return "messaging_exception"; }
|
||||
|
||||
|
||||
//
|
||||
// connection_error
|
||||
//
|
||||
|
||||
connection_error::~connection_error() throw() {}
|
||||
connection_error::connection_error(const exception& other)
|
||||
: messaging_exception("Connection error.", other) {}
|
||||
|
||||
exception* connection_error::clone() const { return new connection_error(*this); }
|
||||
const string connection_error::name() const { return "connection_error"; }
|
||||
|
||||
|
||||
//
|
||||
// connection_greeting_error
|
||||
//
|
||||
|
||||
connection_greeting_error::~connection_greeting_error() throw() {}
|
||||
connection_greeting_error::connection_greeting_error(const string& response, const exception& other)
|
||||
: messaging_exception("Greeting error.", other), m_response(response) {}
|
||||
|
||||
const string& connection_greeting_error::response() const { return (m_response); }
|
||||
|
||||
exception* connection_greeting_error::clone() const { return new connection_greeting_error(*this); }
|
||||
const string connection_greeting_error::name() const { return "connection_greeting_error"; }
|
||||
|
||||
|
||||
//
|
||||
// authentication_error
|
||||
//
|
||||
|
||||
authentication_error::~authentication_error() throw() {}
|
||||
authentication_error::authentication_error(const string& response, const exception& other)
|
||||
: messaging_exception("Authentication error.", other), m_response(response) {}
|
||||
|
||||
const string& authentication_error::response() const { return (m_response); }
|
||||
|
||||
exception* authentication_error::clone() const { return new authentication_error(*this); }
|
||||
const string authentication_error::name() const { return "authentication_error"; }
|
||||
|
||||
|
||||
//
|
||||
// unsupported_option
|
||||
//
|
||||
|
||||
unsupported_option::~unsupported_option() throw() {}
|
||||
unsupported_option::unsupported_option(const exception& other)
|
||||
: messaging_exception("Unsupported option.", other) {}
|
||||
|
||||
exception* unsupported_option::clone() const { return new unsupported_option(*this); }
|
||||
const string unsupported_option::name() const { return "unsupported_option"; }
|
||||
|
||||
|
||||
//
|
||||
// no_service_available
|
||||
//
|
||||
|
||||
no_service_available::~no_service_available() throw() {}
|
||||
no_service_available::no_service_available(const exception& other)
|
||||
: messaging_exception("No service available for this protocol.", other) {}
|
||||
|
||||
exception* no_service_available::clone() const { return new no_service_available(*this); }
|
||||
const string no_service_available::name() const { return "no_service_available"; }
|
||||
|
||||
|
||||
//
|
||||
// illegal_state
|
||||
//
|
||||
|
||||
illegal_state::~illegal_state() throw() {}
|
||||
illegal_state::illegal_state(const string& state, const exception& other)
|
||||
: messaging_exception("Illegal state to accomplish the operation: '" + state + "'.", other) {}
|
||||
|
||||
exception* illegal_state::clone() const { return new illegal_state(*this); }
|
||||
const string illegal_state::name() const { return "illegal_state"; }
|
||||
|
||||
|
||||
//
|
||||
// folder_not_found
|
||||
//
|
||||
|
||||
folder_not_found::~folder_not_found() throw() {}
|
||||
folder_not_found::folder_not_found(const exception& other)
|
||||
: messaging_exception("Folder not found.", other) {}
|
||||
|
||||
exception* folder_not_found::clone() const { return new folder_not_found(*this); }
|
||||
const string folder_not_found::name() const { return "folder_not_found"; }
|
||||
|
||||
|
||||
//
|
||||
// message_not_found
|
||||
//
|
||||
|
||||
message_not_found::~message_not_found() throw() {}
|
||||
message_not_found::message_not_found(const exception& other)
|
||||
: messaging_exception("Message not found.", other) {}
|
||||
|
||||
exception* message_not_found::clone() const { return new message_not_found(*this); }
|
||||
const string message_not_found::name() const { return "message_not_found"; }
|
||||
|
||||
|
||||
//
|
||||
// operation_not_supported
|
||||
//
|
||||
|
||||
operation_not_supported::~operation_not_supported() throw() {}
|
||||
operation_not_supported::operation_not_supported(const exception& other)
|
||||
: messaging_exception("Operation not supported.", other) {}
|
||||
|
||||
exception* operation_not_supported::clone() const { return new operation_not_supported(*this); }
|
||||
const string operation_not_supported::name() const { return "operation_not_supported"; }
|
||||
|
||||
|
||||
//
|
||||
// operation_timed_out
|
||||
//
|
||||
|
||||
operation_timed_out::~operation_timed_out() throw() {}
|
||||
operation_timed_out::operation_timed_out(const exception& other)
|
||||
: messaging_exception("Operation timed out.", other) {}
|
||||
|
||||
exception* operation_timed_out::clone() const { return new operation_timed_out(*this); }
|
||||
const string operation_timed_out::name() const { return "operation_timed_out"; }
|
||||
|
||||
|
||||
//
|
||||
// operation_cancelled
|
||||
//
|
||||
|
||||
operation_cancelled::~operation_cancelled() throw() {}
|
||||
operation_cancelled::operation_cancelled(const exception& other)
|
||||
: messaging_exception("Operation cancelled by the user.", other) {}
|
||||
|
||||
exception* operation_cancelled::clone() const { return new operation_cancelled(*this); }
|
||||
const string operation_cancelled::name() const { return "operation_cancelled"; }
|
||||
|
||||
|
||||
//
|
||||
// unfetched_object
|
||||
//
|
||||
|
||||
unfetched_object::~unfetched_object() throw() {}
|
||||
unfetched_object::unfetched_object(const exception& other)
|
||||
: messaging_exception("Object not fetched.", other) {}
|
||||
|
||||
exception* unfetched_object::clone() const { return new unfetched_object(*this); }
|
||||
const string unfetched_object::name() const { return "unfetched_object"; }
|
||||
|
||||
|
||||
//
|
||||
// not_connected
|
||||
//
|
||||
|
||||
not_connected::~not_connected() throw() {}
|
||||
not_connected::not_connected(const exception& other)
|
||||
: messaging_exception("Not connected to a service.", other) {}
|
||||
|
||||
exception* not_connected::clone() const { return new not_connected(*this); }
|
||||
const string not_connected::name() const { return "not_connected"; }
|
||||
|
||||
|
||||
//
|
||||
// already_connected
|
||||
//
|
||||
|
||||
already_connected::~already_connected() throw() {}
|
||||
already_connected::already_connected(const exception& other)
|
||||
: messaging_exception("Already connected to a service. Disconnect and retry.", other) {}
|
||||
|
||||
exception* already_connected::clone() const { return new already_connected(*this); }
|
||||
const string already_connected::name() const { return "already_connected"; }
|
||||
|
||||
|
||||
//
|
||||
// illegal_operation
|
||||
//
|
||||
|
||||
illegal_operation::~illegal_operation() throw() {}
|
||||
illegal_operation::illegal_operation(const string& msg, const exception& other)
|
||||
: messaging_exception(msg.empty()
|
||||
? "Illegal operation."
|
||||
: "Illegal operation: " + msg + ".",
|
||||
other
|
||||
) {}
|
||||
|
||||
exception* illegal_operation::clone() const { return new illegal_operation(*this); }
|
||||
const string illegal_operation::name() const { return "illegal_operation"; }
|
||||
|
||||
|
||||
//
|
||||
// command_error
|
||||
//
|
||||
|
||||
command_error::~command_error() throw() {}
|
||||
command_error::command_error(const string& command, const string& response,
|
||||
const string& desc, const exception& other)
|
||||
: messaging_exception(desc.empty()
|
||||
? "Error while executing command '" + command + "'."
|
||||
: "Error while executing command '" + command + "': " + desc + ".",
|
||||
other
|
||||
),
|
||||
m_command(command), m_response(response) {}
|
||||
|
||||
const string& command_error::command() const { return (m_command); }
|
||||
|
||||
const string& command_error::response() const { return (m_response); }
|
||||
|
||||
exception* command_error::clone() const { return new command_error(*this); }
|
||||
const string command_error::name() const { return "command_error"; }
|
||||
|
||||
|
||||
//
|
||||
// invalid_response
|
||||
//
|
||||
|
||||
invalid_response::~invalid_response() throw() {}
|
||||
invalid_response::invalid_response(const string& command, const string& response, const exception& other)
|
||||
: messaging_exception(command.empty()
|
||||
? "Received invalid response."
|
||||
: "Received invalid response for command '" + command + "'.",
|
||||
other
|
||||
),
|
||||
m_command(command), m_response(response) {}
|
||||
|
||||
const string& invalid_response::command() const { return (m_command); }
|
||||
|
||||
const string& invalid_response::response() const { return (m_response); }
|
||||
|
||||
exception* invalid_response::clone() const { return new invalid_response(*this); }
|
||||
const string invalid_response::name() const { return "invalid_response"; }
|
||||
|
||||
|
||||
//
|
||||
// partial_fetch_not_supported
|
||||
//
|
||||
|
||||
partial_fetch_not_supported::~partial_fetch_not_supported() throw() {}
|
||||
partial_fetch_not_supported::partial_fetch_not_supported(const exception& other)
|
||||
: messaging_exception("Partial fetch not supported.", other) {}
|
||||
|
||||
exception* partial_fetch_not_supported::clone() const { return new partial_fetch_not_supported(*this); }
|
||||
const string partial_fetch_not_supported::name() const { return "partial_fetch_not_supported"; }
|
||||
|
||||
|
||||
//
|
||||
// malformed_url
|
||||
//
|
||||
|
||||
malformed_url::~malformed_url() throw() {}
|
||||
malformed_url::malformed_url(const string& error, const exception& other)
|
||||
: messaging_exception("Malformed URL: " + error + ".", other) {}
|
||||
|
||||
exception* malformed_url::clone() const { return new malformed_url(*this); }
|
||||
const string malformed_url::name() const { return "malformed_url"; }
|
||||
|
||||
|
||||
//
|
||||
// invalid_folder_name
|
||||
//
|
||||
|
||||
invalid_folder_name::~invalid_folder_name() throw() {}
|
||||
invalid_folder_name::invalid_folder_name(const string& error, const exception& other)
|
||||
: messaging_exception(error.empty()
|
||||
? "Invalid folder name: " + error + "."
|
||||
: "Invalid folder name.",
|
||||
other) {}
|
||||
|
||||
exception* invalid_folder_name::clone() const { return new invalid_folder_name(*this); }
|
||||
const string invalid_folder_name::name() const { return "invalid_folder_name"; }
|
||||
|
||||
|
||||
#endif // VMIME_HAVE_MESSAGING_FEATURES
|
||||
|
||||
|
||||
#if VMIME_HAVE_FILESYSTEM_FEATURES
|
||||
|
||||
|
||||
//
|
||||
// filesystem_exception
|
||||
//
|
||||
|
||||
filesystem_exception::~filesystem_exception() throw() {}
|
||||
filesystem_exception::filesystem_exception(const string& what, const utility::path& path, const exception& other)
|
||||
: exception(what, other), m_path(path) {}
|
||||
|
||||
const utility::path& filesystem_exception::path() const { return (m_path); }
|
||||
|
||||
exception* filesystem_exception::clone() const { return new filesystem_exception(*this); }
|
||||
const string filesystem_exception::name() const { return "filesystem_exception"; }
|
||||
|
||||
|
||||
//
|
||||
// not_a_directory
|
||||
//
|
||||
|
||||
not_a_directory::~not_a_directory() throw() {}
|
||||
not_a_directory::not_a_directory(const utility::path& path, const exception& other)
|
||||
: filesystem_exception("Operation failed: this is not a directory.", path, other) {}
|
||||
|
||||
exception* not_a_directory::clone() const { return new not_a_directory(*this); }
|
||||
const string not_a_directory::name() const { return "not_a_directory"; }
|
||||
|
||||
|
||||
//
|
||||
// file_not_found
|
||||
//
|
||||
|
||||
file_not_found::~file_not_found() throw() {}
|
||||
file_not_found::file_not_found(const utility::path& path, const exception& other)
|
||||
: filesystem_exception("File not found.", path, other) {}
|
||||
|
||||
exception* file_not_found::clone() const { return new file_not_found(*this); }
|
||||
const string file_not_found::name() const { return "file_not_found"; }
|
||||
|
||||
|
||||
#endif // VMIME_HAVE_FILESYSTEM_FEATURES
|
||||
|
||||
|
||||
} // exceptions
|
||||
|
||||
|
||||
} // vmime
|
@ -32,19 +32,45 @@ namespace vmime
|
||||
|
||||
class exception
|
||||
{
|
||||
protected:
|
||||
private:
|
||||
|
||||
string m_what;
|
||||
exception* m_other;
|
||||
|
||||
exception();
|
||||
|
||||
public:
|
||||
|
||||
exception(const string& what) : m_what(what) { }
|
||||
virtual ~exception() { }
|
||||
exception(const string& what, const exception& other = NO_EXCEPTION);
|
||||
virtual ~exception();
|
||||
|
||||
const string what() const throw() { return (m_what); };
|
||||
/** Return a description of the error.
|
||||
*
|
||||
* @return error message
|
||||
*/
|
||||
const string what() const throw();
|
||||
|
||||
/** Return the next exception in the chain (encapsuled exception).
|
||||
*
|
||||
* @return next exception in the chain
|
||||
*/
|
||||
const exception* other() const;
|
||||
|
||||
/** Return a name identifying the exception.
|
||||
*
|
||||
* @return exception name
|
||||
*/
|
||||
virtual const string name() const;
|
||||
|
||||
protected:
|
||||
|
||||
static const exception NO_EXCEPTION;
|
||||
|
||||
virtual exception* clone() const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** List of all VMime exceptions. */
|
||||
|
||||
namespace exceptions
|
||||
@ -55,8 +81,11 @@ class bad_field_type : public vmime::exception
|
||||
{
|
||||
public:
|
||||
|
||||
bad_field_type() : exception("Bad field type.") {}
|
||||
~bad_field_type() throw() {}
|
||||
bad_field_type(const exception& other = NO_EXCEPTION);
|
||||
~bad_field_type() throw();
|
||||
|
||||
exception* clone() const;
|
||||
const string name() const;
|
||||
};
|
||||
|
||||
|
||||
@ -64,8 +93,11 @@ class charset_conv_error : public vmime::exception
|
||||
{
|
||||
public:
|
||||
|
||||
charset_conv_error() : exception("Charset conversion error.") {}
|
||||
~charset_conv_error() throw() {}
|
||||
charset_conv_error(const exception& other = NO_EXCEPTION);
|
||||
~charset_conv_error() throw();
|
||||
|
||||
exception* clone() const;
|
||||
const string name() const;
|
||||
};
|
||||
|
||||
|
||||
@ -73,8 +105,11 @@ class no_encoder_available : public vmime::exception
|
||||
{
|
||||
public:
|
||||
|
||||
no_encoder_available() : exception("No encoder available.") {}
|
||||
~no_encoder_available() throw() {}
|
||||
no_encoder_available(const exception& other = NO_EXCEPTION);
|
||||
~no_encoder_available() throw();
|
||||
|
||||
exception* clone() const;
|
||||
const string name() const;
|
||||
};
|
||||
|
||||
|
||||
@ -82,9 +117,11 @@ class no_such_parameter : public vmime::exception
|
||||
{
|
||||
public:
|
||||
|
||||
no_such_parameter(const string& name) : exception
|
||||
(string("Parameter not found: '") + name + string("'.")) {}
|
||||
~no_such_parameter() throw() {}
|
||||
no_such_parameter(const string& name, const exception& other = NO_EXCEPTION);
|
||||
~no_such_parameter() throw();
|
||||
|
||||
exception* clone() const;
|
||||
const string name() const;
|
||||
};
|
||||
|
||||
|
||||
@ -92,8 +129,11 @@ class no_such_field : public vmime::exception
|
||||
{
|
||||
public:
|
||||
|
||||
no_such_field() : exception("Field not found.") {}
|
||||
~no_such_field() throw() {}
|
||||
no_such_field(const exception& other = NO_EXCEPTION);
|
||||
~no_such_field() throw();
|
||||
|
||||
exception* clone() const;
|
||||
const string name() const;
|
||||
};
|
||||
|
||||
|
||||
@ -101,8 +141,11 @@ class no_such_part : public vmime::exception
|
||||
{
|
||||
public:
|
||||
|
||||
no_such_part() : exception("Part not found.") {}
|
||||
~no_such_part() throw() {}
|
||||
no_such_part(const exception& other = NO_EXCEPTION);
|
||||
~no_such_part() throw();
|
||||
|
||||
exception* clone() const;
|
||||
const string name() const;
|
||||
};
|
||||
|
||||
|
||||
@ -110,8 +153,11 @@ class no_such_mailbox : public vmime::exception
|
||||
{
|
||||
public:
|
||||
|
||||
no_such_mailbox() : exception("Mailbox not found.") {}
|
||||
~no_such_mailbox() throw() {}
|
||||
no_such_mailbox(const exception& other = NO_EXCEPTION);
|
||||
~no_such_mailbox() throw();
|
||||
|
||||
exception* clone() const;
|
||||
const string name() const;
|
||||
};
|
||||
|
||||
|
||||
@ -119,8 +165,11 @@ class no_such_address : public vmime::exception
|
||||
{
|
||||
public:
|
||||
|
||||
no_such_address() : exception("Address not found.") {}
|
||||
~no_such_address() throw() {}
|
||||
no_such_address(const exception& other = NO_EXCEPTION);
|
||||
~no_such_address() throw();
|
||||
|
||||
exception* clone() const;
|
||||
const string name() const;
|
||||
};
|
||||
|
||||
|
||||
@ -128,8 +177,11 @@ class open_file_error : public vmime::exception
|
||||
{
|
||||
public:
|
||||
|
||||
open_file_error() : exception("Error opening file.") {}
|
||||
~open_file_error() throw() {}
|
||||
open_file_error(const exception& other = NO_EXCEPTION);
|
||||
~open_file_error() throw();
|
||||
|
||||
exception* clone() const;
|
||||
const string name() const;
|
||||
};
|
||||
|
||||
|
||||
@ -137,8 +189,11 @@ class no_factory_available : public vmime::exception
|
||||
{
|
||||
public:
|
||||
|
||||
no_factory_available() : exception("No factory available.") {}
|
||||
~no_factory_available() throw() {}
|
||||
no_factory_available(const exception& other = NO_EXCEPTION);
|
||||
~no_factory_available() throw();
|
||||
|
||||
exception* clone() const;
|
||||
const string name() const;
|
||||
};
|
||||
|
||||
|
||||
@ -146,26 +201,41 @@ class no_platform_dependant_handler : public vmime::exception
|
||||
{
|
||||
public:
|
||||
|
||||
no_platform_dependant_handler() : exception("No platform-dependant handler installed.") {}
|
||||
~no_platform_dependant_handler() throw() {}
|
||||
no_platform_dependant_handler(const exception& other = NO_EXCEPTION);
|
||||
~no_platform_dependant_handler() throw();
|
||||
|
||||
exception* clone() const;
|
||||
const string name() const;
|
||||
};
|
||||
|
||||
|
||||
/** No expeditor specified.
|
||||
*/
|
||||
|
||||
class no_expeditor : public vmime::exception
|
||||
{
|
||||
public:
|
||||
|
||||
no_expeditor() : exception("No expeditor specified.") {}
|
||||
~no_expeditor() throw() {}
|
||||
no_expeditor(const exception& other = NO_EXCEPTION);
|
||||
~no_expeditor() throw();
|
||||
|
||||
exception* clone() const;
|
||||
const string name() const;
|
||||
};
|
||||
|
||||
|
||||
/** No recipient specified.
|
||||
*/
|
||||
|
||||
class no_recipient : public vmime::exception
|
||||
{
|
||||
public:
|
||||
|
||||
no_recipient() : exception("No recipient specified.") {}
|
||||
~no_recipient() throw() {}
|
||||
no_recipient(const exception& other = NO_EXCEPTION);
|
||||
~no_recipient() throw();
|
||||
|
||||
exception* clone() const;
|
||||
const string name() const;
|
||||
};
|
||||
|
||||
|
||||
@ -173,42 +243,56 @@ class no_object_found : public vmime::exception
|
||||
{
|
||||
public:
|
||||
|
||||
no_object_found() : exception("No object found.") {}
|
||||
~no_object_found() throw() {}
|
||||
no_object_found(const exception& other = NO_EXCEPTION);
|
||||
~no_object_found() throw();
|
||||
|
||||
exception* clone() const;
|
||||
const string name() const;
|
||||
};
|
||||
|
||||
|
||||
// There is no property with that name in the set.
|
||||
/** There is no property with that name in the set.
|
||||
*/
|
||||
|
||||
class no_such_property : public vmime::exception
|
||||
{
|
||||
public:
|
||||
|
||||
no_such_property(const string& name) : exception
|
||||
(std::string("No such property: '") + name + string("'.")) { }
|
||||
~no_such_property() throw() {}
|
||||
no_such_property(const string& name, const exception& other = NO_EXCEPTION);
|
||||
~no_such_property() throw();
|
||||
|
||||
exception* clone() const;
|
||||
const string name() const;
|
||||
};
|
||||
|
||||
|
||||
// Bad type specified when reading property.
|
||||
/** Bad type specified when reading property.
|
||||
*/
|
||||
|
||||
class invalid_property_type : public vmime::exception
|
||||
{
|
||||
public:
|
||||
|
||||
invalid_property_type() : exception("Invalid property type.") {}
|
||||
~invalid_property_type() throw() {}
|
||||
invalid_property_type(const exception& other = NO_EXCEPTION);
|
||||
~invalid_property_type() throw();
|
||||
|
||||
exception* clone() const;
|
||||
const string name() const;
|
||||
};
|
||||
|
||||
|
||||
// Bad argument was passed to the function.
|
||||
/** Bad argument was passed to the function.
|
||||
*/
|
||||
|
||||
class invalid_argument : public vmime::exception
|
||||
{
|
||||
public:
|
||||
|
||||
invalid_argument() : exception("Invalid argument.") {}
|
||||
~invalid_argument() throw() {}
|
||||
invalid_argument(const exception& other = NO_EXCEPTION);
|
||||
~invalid_argument() throw();
|
||||
|
||||
exception* clone() const;
|
||||
const string name() const;
|
||||
};
|
||||
|
||||
|
||||
@ -223,8 +307,11 @@ class messaging_exception : public vmime::exception
|
||||
{
|
||||
public:
|
||||
|
||||
messaging_exception(const string& what) : exception(what) {}
|
||||
~messaging_exception() throw() {}
|
||||
messaging_exception(const string& what, const exception& other = NO_EXCEPTION);
|
||||
~messaging_exception() throw();
|
||||
|
||||
exception* clone() const;
|
||||
const string name() const;
|
||||
};
|
||||
|
||||
|
||||
@ -236,8 +323,11 @@ class connection_error : public messaging_exception
|
||||
{
|
||||
public:
|
||||
|
||||
connection_error() : messaging_exception("Connection error.") {}
|
||||
~connection_error() throw() {}
|
||||
connection_error(const exception& other = NO_EXCEPTION);
|
||||
~connection_error() throw();
|
||||
|
||||
exception* clone() const;
|
||||
const string name() const;
|
||||
};
|
||||
|
||||
|
||||
@ -248,11 +338,13 @@ class connection_greeting_error : public messaging_exception
|
||||
{
|
||||
public:
|
||||
|
||||
connection_greeting_error(const string& response)
|
||||
: messaging_exception("Greeting error."), m_response(response) {}
|
||||
~connection_greeting_error() throw() {}
|
||||
connection_greeting_error(const string& response, const exception& other = NO_EXCEPTION);
|
||||
~connection_greeting_error() throw();
|
||||
|
||||
const string& response() const { return (m_response); }
|
||||
const string& response() const;
|
||||
|
||||
exception* clone() const;
|
||||
const string name() const;
|
||||
|
||||
private:
|
||||
|
||||
@ -268,11 +360,13 @@ class authentication_error : public messaging_exception
|
||||
{
|
||||
public:
|
||||
|
||||
authentication_error(const string& response)
|
||||
: messaging_exception("Authentication error."), m_response(response) {}
|
||||
~authentication_error() throw() {}
|
||||
authentication_error(const string& response, const exception& other = NO_EXCEPTION);
|
||||
~authentication_error() throw();
|
||||
|
||||
const string& response() const { return (m_response); }
|
||||
const string& response() const;
|
||||
|
||||
exception* clone() const;
|
||||
const string name() const;
|
||||
|
||||
private:
|
||||
|
||||
@ -287,8 +381,11 @@ class unsupported_option : public messaging_exception
|
||||
{
|
||||
public:
|
||||
|
||||
unsupported_option() : messaging_exception("Unsupported option.") {}
|
||||
~unsupported_option() throw() {}
|
||||
unsupported_option(const exception& other = NO_EXCEPTION);
|
||||
~unsupported_option() throw();
|
||||
|
||||
exception* clone() const;
|
||||
const string name() const;
|
||||
};
|
||||
|
||||
|
||||
@ -299,8 +396,11 @@ class no_service_available : public messaging_exception
|
||||
{
|
||||
public:
|
||||
|
||||
no_service_available() : messaging_exception("No service available for this protocol.") {}
|
||||
~no_service_available() throw() {}
|
||||
no_service_available(const exception& other = NO_EXCEPTION);
|
||||
~no_service_available() throw();
|
||||
|
||||
exception* clone() const;
|
||||
const string name() const;
|
||||
};
|
||||
|
||||
|
||||
@ -312,9 +412,11 @@ class illegal_state : public messaging_exception
|
||||
{
|
||||
public:
|
||||
|
||||
illegal_state(const string& state)
|
||||
: messaging_exception("Illegal state to accomplish the operation: '" + state + "'.") {}
|
||||
~illegal_state() throw() {}
|
||||
illegal_state(const string& state, const exception& other = NO_EXCEPTION);
|
||||
~illegal_state() throw();
|
||||
|
||||
exception* clone() const;
|
||||
const string name() const;
|
||||
};
|
||||
|
||||
|
||||
@ -325,8 +427,11 @@ class folder_not_found : public messaging_exception
|
||||
{
|
||||
public:
|
||||
|
||||
folder_not_found() : messaging_exception("Folder not found.") {}
|
||||
~folder_not_found() throw() {}
|
||||
folder_not_found(const exception& other = NO_EXCEPTION);
|
||||
~folder_not_found() throw();
|
||||
|
||||
exception* clone() const;
|
||||
const string name() const;
|
||||
};
|
||||
|
||||
|
||||
@ -337,8 +442,11 @@ class message_not_found : public messaging_exception
|
||||
{
|
||||
public:
|
||||
|
||||
message_not_found() : messaging_exception("Message not found.") {}
|
||||
~message_not_found() throw() {}
|
||||
message_not_found(const exception& other = NO_EXCEPTION);
|
||||
~message_not_found() throw();
|
||||
|
||||
exception* clone() const;
|
||||
const string name() const;
|
||||
};
|
||||
|
||||
|
||||
@ -349,8 +457,11 @@ class operation_not_supported : public messaging_exception
|
||||
{
|
||||
public:
|
||||
|
||||
operation_not_supported() : messaging_exception("Operation not supported.") {}
|
||||
~operation_not_supported() throw() {}
|
||||
operation_not_supported(const exception& other = NO_EXCEPTION);
|
||||
~operation_not_supported() throw();
|
||||
|
||||
exception* clone() const;
|
||||
const string name() const;
|
||||
};
|
||||
|
||||
|
||||
@ -361,8 +472,11 @@ class operation_timed_out : public messaging_exception
|
||||
{
|
||||
public:
|
||||
|
||||
operation_timed_out() : messaging_exception("Operation timed out.") {}
|
||||
~operation_timed_out() throw() {}
|
||||
operation_timed_out(const exception& other = NO_EXCEPTION);
|
||||
~operation_timed_out() throw();
|
||||
|
||||
exception* clone() const;
|
||||
const string name() const;
|
||||
};
|
||||
|
||||
|
||||
@ -373,8 +487,11 @@ class operation_cancelled : public messaging_exception
|
||||
{
|
||||
public:
|
||||
|
||||
operation_cancelled() : messaging_exception("Operation cancelled by the user.") {}
|
||||
~operation_cancelled() throw() {}
|
||||
operation_cancelled(const exception& other = NO_EXCEPTION);
|
||||
~operation_cancelled() throw();
|
||||
|
||||
exception* clone() const;
|
||||
const string name() const;
|
||||
};
|
||||
|
||||
|
||||
@ -386,8 +503,11 @@ class unfetched_object : public messaging_exception
|
||||
{
|
||||
public:
|
||||
|
||||
unfetched_object() : messaging_exception("Object not fetched.") {}
|
||||
~unfetched_object() throw() {}
|
||||
unfetched_object(const exception& other = NO_EXCEPTION);
|
||||
~unfetched_object() throw();
|
||||
|
||||
exception* clone() const;
|
||||
const string name() const;
|
||||
};
|
||||
|
||||
|
||||
@ -398,8 +518,11 @@ class not_connected : public messaging_exception
|
||||
{
|
||||
public:
|
||||
|
||||
not_connected() : messaging_exception("Not connected to a service.") {}
|
||||
~not_connected() throw() {}
|
||||
not_connected(const exception& other = NO_EXCEPTION);
|
||||
~not_connected() throw();
|
||||
|
||||
exception* clone() const;
|
||||
const string name() const;
|
||||
};
|
||||
|
||||
|
||||
@ -410,8 +533,11 @@ class already_connected : public messaging_exception
|
||||
{
|
||||
public:
|
||||
|
||||
already_connected() : messaging_exception("Already connected to a service. Disconnect and retry.") {}
|
||||
~already_connected() throw() {}
|
||||
already_connected(const exception& other = NO_EXCEPTION);
|
||||
~already_connected() throw();
|
||||
|
||||
exception* clone() const;
|
||||
const string name() const;
|
||||
};
|
||||
|
||||
|
||||
@ -422,12 +548,11 @@ class illegal_operation : public messaging_exception
|
||||
{
|
||||
public:
|
||||
|
||||
illegal_operation(const string& msg = "")
|
||||
: messaging_exception(msg.empty()
|
||||
? "Illegal operation."
|
||||
: "Illegal operation: " + msg + "."
|
||||
) {}
|
||||
~illegal_operation() throw() {}
|
||||
illegal_operation(const string& msg = "", const exception& other = NO_EXCEPTION);
|
||||
~illegal_operation() throw();
|
||||
|
||||
exception* clone() const;
|
||||
const string name() const;
|
||||
};
|
||||
|
||||
|
||||
@ -438,27 +563,25 @@ class command_error : public messaging_exception
|
||||
{
|
||||
public:
|
||||
|
||||
command_error(const string& command, const string& response, const string& desc = "")
|
||||
: messaging_exception(desc.empty()
|
||||
? "Error while executing command '" + command + "'."
|
||||
: "Error while executing command '" + command + "': " + desc + "."
|
||||
),
|
||||
m_command(command), m_response(response) {}
|
||||
~command_error() throw() {}
|
||||
command_error(const string& command, const string& response, const string& desc = "", const exception& other = NO_EXCEPTION);
|
||||
~command_error() throw();
|
||||
|
||||
/** Return the name of the command which have thrown the exception.
|
||||
* This is protocol-dependant.
|
||||
*
|
||||
* @return command name (protocol-dependant)
|
||||
*/
|
||||
const string& command() const { return (m_command); }
|
||||
const string& command() const;
|
||||
|
||||
/** Return the invalid response line.
|
||||
* The meaning is protocol-dependant.
|
||||
*
|
||||
* @return response line (protocol-dependant)
|
||||
*/
|
||||
const string& response() const { return (m_response); }
|
||||
const string& response() const;
|
||||
|
||||
exception* clone() const;
|
||||
const string name() const;
|
||||
|
||||
private:
|
||||
|
||||
@ -474,27 +597,25 @@ class invalid_response : public messaging_exception
|
||||
{
|
||||
public:
|
||||
|
||||
invalid_response(const string& command, const string& response)
|
||||
: messaging_exception(command.empty()
|
||||
? "Received invalid response."
|
||||
: "Received invalid response for command '" + command + "'."
|
||||
),
|
||||
m_command(command), m_response(response) {}
|
||||
~invalid_response() throw() {}
|
||||
invalid_response(const string& command, const string& response, const exception& other = NO_EXCEPTION);
|
||||
~invalid_response() throw();
|
||||
|
||||
/** Return the name of the command which have thrown the exception.
|
||||
* This is protocol-dependant.
|
||||
*
|
||||
* @return command name (protocol-dependant)
|
||||
*/
|
||||
const string& command() const { return (m_command); }
|
||||
const string& command() const;
|
||||
|
||||
/** Return the invalid response line.
|
||||
* The meaning is protocol-dependant.
|
||||
*
|
||||
* @return response line (protocol-dependant)
|
||||
*/
|
||||
const string& response() const { return (m_response); }
|
||||
const string& response() const;
|
||||
|
||||
exception* clone() const;
|
||||
const string name() const;
|
||||
|
||||
private:
|
||||
|
||||
@ -510,8 +631,11 @@ class partial_fetch_not_supported : public messaging_exception
|
||||
{
|
||||
public:
|
||||
|
||||
partial_fetch_not_supported() : messaging_exception("Partial fetch not supported.") {}
|
||||
~partial_fetch_not_supported() throw() {}
|
||||
partial_fetch_not_supported(const exception& other = NO_EXCEPTION);
|
||||
~partial_fetch_not_supported() throw();
|
||||
|
||||
exception* clone() const;
|
||||
const string name() const;
|
||||
};
|
||||
|
||||
|
||||
@ -522,8 +646,11 @@ class malformed_url : public messaging_exception
|
||||
{
|
||||
public:
|
||||
|
||||
malformed_url(const string& error) : messaging_exception("Malformed URL: " + error + ".") {}
|
||||
~malformed_url() throw() {}
|
||||
malformed_url(const string& error, const exception& other = NO_EXCEPTION);
|
||||
~malformed_url() throw();
|
||||
|
||||
exception* clone() const;
|
||||
const string name() const;
|
||||
};
|
||||
|
||||
|
||||
@ -534,11 +661,11 @@ class invalid_folder_name : public messaging_exception
|
||||
{
|
||||
public:
|
||||
|
||||
invalid_folder_name(const string& error = "")
|
||||
: messaging_exception(error.empty()
|
||||
? "Invalid folder name: " + error + "."
|
||||
: "Invalid folder name.") {}
|
||||
~invalid_folder_name() throw() {}
|
||||
invalid_folder_name(const string& error = "", const exception& other = NO_EXCEPTION);
|
||||
~invalid_folder_name() throw();
|
||||
|
||||
exception* clone() const;
|
||||
const string name() const;
|
||||
};
|
||||
|
||||
|
||||
@ -555,14 +682,17 @@ class filesystem_exception : public vmime::exception
|
||||
{
|
||||
public:
|
||||
|
||||
filesystem_exception(const string& what, const utility::path& path) : exception(what), m_path(path) {}
|
||||
~filesystem_exception() throw() {}
|
||||
filesystem_exception(const string& what, const utility::path& path, const exception& other = NO_EXCEPTION);
|
||||
~filesystem_exception() throw();
|
||||
|
||||
/** Return the full path of the file have thrown the exception.
|
||||
*
|
||||
* @return full path of the file/directory
|
||||
*/
|
||||
const utility::path& path() const { return (m_path); }
|
||||
const utility::path& path() const;
|
||||
|
||||
exception* clone() const;
|
||||
const string name() const;
|
||||
|
||||
private:
|
||||
|
||||
@ -577,8 +707,11 @@ class not_a_directory : public filesystem_exception
|
||||
{
|
||||
public:
|
||||
|
||||
not_a_directory(const utility::path& path) : filesystem_exception("Operation failed: this is not a directory.", path) {}
|
||||
~not_a_directory() throw() {}
|
||||
not_a_directory(const utility::path& path, const exception& other = NO_EXCEPTION);
|
||||
~not_a_directory() throw();
|
||||
|
||||
exception* clone() const;
|
||||
const string name() const;
|
||||
};
|
||||
|
||||
|
||||
@ -589,8 +722,11 @@ class file_not_found : public filesystem_exception
|
||||
{
|
||||
public:
|
||||
|
||||
file_not_found(const utility::path& path) : filesystem_exception("File not found.", path) {}
|
||||
~file_not_found() throw() {}
|
||||
file_not_found(const utility::path& path, const exception& other = NO_EXCEPTION);
|
||||
~file_not_found() throw();
|
||||
|
||||
exception* clone() const;
|
||||
const string name() const;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user