Add loots of comments to get an overview which errors/exceptions I might catch and raise

master
Gernot Kranz 2 months ago
parent 3e4caf6c9d
commit c8ba7f1734

@ -48,5 +48,6 @@ pEp::mailio_message::mailio_message(::message* msg)
std::string subtype = mime_string.substr(delim_pos + 1, -1);
attach(s, _attach->filename, type, subtype);
}
// message fields not handed to mailio: keywords, comments, refered_by, enc_format, _sender_fpr, rating, refering_msg_ref, any timestamp, rawmsg_ref, rawmsg_size, longmsg_formatted, dir.
// message fields not handed to mailio: keywords, comments, refered_by, enc_format, _sender_fpr,
// rating, refering_msg_ref, any timestamp, rawmsg_ref, rawmsg_size, longmsg_formatted, dir. (TODO)
}

@ -79,7 +79,7 @@ namespace pEp {
pEpLogClass("called");
throwInvalidState();
// moved to startup()
// and then populate rx_queue via conn_imap.select()
// populate rx_queue via conn_imap.select()
try {
conn_imap = new mailio::imaps(login_imap.server, login_imap.port);
} catch (mailio::dialog_error e) {
@ -151,27 +151,56 @@ namespace pEp {
// PEP_tsc_no_send_config
// PEP_tsc_send_config_incomplete_or_wrong
mailio::smtps *conn;
conn = new mailio::smtps(login_smtp.server, login_smtp.port);
// That would make this check obsolete (and it doesn't work as intended anyways)
if (conn->source_hostname().empty()) {
pEpLogClass("SMTP no connection");
} else {
pEpLogClass("SMTP connected to " + conn->source_hostname());
try {
conn = new mailio::smtps(login_smtp.server, login_smtp.port);
} catch (mailio::dialog_error e) {
// e.what() might be:
// Server connecting failed
// Server connecting timed out
throw(TransportError(PEP_tsc_cannot_reach_smtp_server));
} catch (mailio::smtp_error e) {
throw(TransportError(PEP_tsc_send_config_incomplete_or_wrong));
}
try {
conn->authenticate(login_smtp.username, login_smtp.passphrase, login_smtp.auth_method);
} catch (mailio::smtp_error e) {
// e.what() might be:
// Connection rejection
// Initial message rejection
// Authentication rejection
// Username rejection
// Password rejection
// Parsing server failure
pep_tsc = PEP_tsc_cannot_reach_smtp_server;
throw(TransportError(pep_tsc));
// Other possible values:
// PEP_tsc_network_timeout = 0x0080000a,
// PEP_tsc_unknown_smtp_error = 0x01801fff,
// PEP_tsc_no_send_config
// PEP_tsc_send_config_incomplete_or_wrong
} catch (mailio::dialog_error e) {
// e.what() might be:
// Network sending error
// Network sending failed
// Network sending out
// Network receiving error
// Network receiving failed
// Network receiving timed out
}
try {
std::string answer = conn->submit(mmsg); // TODO: log the result
pEpLogClass(answer);
} catch (mailio::smtp_error e) {
// e.what() might be:
// Parsing server failure
// Mail sender rejection.
// Mail recipient rejection.
// Mail group recipient rejection.
// Mail cc recipient rejection.
// Mail group cc recipient rejection.
// Mail bcc recipient rejection.
// Mail group bcc recipient rejection.
// Mail message rejection.
pEpLogClass(e.what());
pep_tsc = PEP_tsc_could_not_deliver_giving_up;
// Possible values depending on the error code:
@ -182,6 +211,14 @@ namespace pEp {
// PEP_tsc_could_not_deliver_giving_up = 0x0080000b,
// PEP_tsc_cannot_reach_smtp_server = 0x01801001,
// PEP_tsc_unknown_smtp_error = 0x01801fff,
} catch (mailio::dialog_error e) {
// e.what() might be:
// Network sending error
// Network sending failed
// Network sending out
// Network receiving error
// Network receiving failed
// Network receiving timed out
}
// if nothing failed, pep_tsc is still PEP_tsc_message_on_the_way
cb_sendto_result(get_id(), msg->id, pep_tsc);
@ -190,7 +227,26 @@ namespace pEp {
// This usually fails in the test, I don't know why.
// And I'm not even sure if it's a) needed or b) even asked for?
} catch (mailio::imap_error e) {
// e.what() might be:
// Message appending failure
// Parsing failure
pEpLogClass(e.what());
} catch (mailio::dialog_error e) {
// e.what() might be:
// Network sending error
// Network sending failed
// Network sending out
// Network receiving error
// Network receiving failed
// Network receiving timed out
} catch (mailio::message_error e) {
// e.what() might be:
// No boundary for multipart message.
// No author.
// No sender for multiple authors.
} catch (mailio::mime_error e) {
// e.what() might be:
// Formatting failure, non multipart message with boundary.
}
}
@ -219,8 +275,27 @@ namespace pEp {
try {
conn_imap->fetch("inbox", message_id, mmsg, false);
} catch (mailio::imap_error e) {
// e.what() could be:
// Fetching message failure.
// Parsing failure
pEpLogClass(e.what());
throw(TransportError(PEP_tsc_unknown_imap_error));
} catch (mailio::message_error) {
// message_error No author address
} catch (mailio::mime_error) {
// lots of mime_error's
} catch (mailio::dialog_error e) {
// e.what() might be:
// Network sending error
// Network sending failed
// Network sending out
// Network receiving error
// Network receiving failed
// Network receiving timed out
} catch (std::logic_error e) {
// e might be of class:
// std::invalid_argument
// std::out_of_rangev
}
// Convert the mailio message struct into a pEp message struct using our conversion operator.

Loading…
Cancel
Save