Merge branch 'wip/problem-report-cleanup' into 'master'

Problem report cleanup

See merge request GNOME/geary!177
This commit is contained in:
Michael Gratton 2019-03-23 03:56:42 +00:00
commit 2d5cde490f
7 changed files with 61 additions and 279 deletions

View file

@ -260,11 +260,7 @@ public class Accounts.Manager : GLib.Object {
// load_account.
} catch (GLib.Error err) {
debug("Error loading account %s", id);
report_problem(
new Geary.ProblemReport(
Geary.ProblemType.GENERIC_ERROR,
err
));
report_problem(new Geary.ProblemReport(err));
}
}
}
@ -819,11 +815,7 @@ public class Accounts.Manager : GLib.Object {
yield save_account(info, cancellable);
yield mediator.update(info, cancellable);
} catch (GLib.Error err) {
report_problem(
new Geary.ProblemReport(
Geary.ProblemType.GENERIC_ERROR,
err
));
report_problem(new Geary.ProblemReport(err));
}
set_enabled(info, true);
@ -850,12 +842,7 @@ public class Accounts.Manager : GLib.Object {
yield account.load_incoming_credentials(cancellable);
}
} catch (GLib.Error err) {
report_problem(
new Geary.AccountProblemReport(
Geary.ProblemType.GENERIC_ERROR,
account,
err
));
report_problem(new Geary.AccountProblemReport(account, err));
}
set_available(account, is_available);
@ -960,13 +947,7 @@ public class Accounts.Manager : GLib.Object {
try {
this.save_account.end(res);
} catch (GLib.Error err) {
report_problem(
new Geary.AccountProblemReport(
Geary.ProblemType.GENERIC_ERROR,
account,
err
)
);
report_problem(new Geary.AccountProblemReport(account, err));
}
}
);

View file

@ -1,6 +1,6 @@
/*
* Copyright 2016 Software Freedom Conservancy Inc.
* Copyright 2016-2018 Michael Gratton <mike@vee.net>
* Copyright 2016-2019 Michael Gratton <mike@vee.net>
*
* This software is licensed under the GNU Lesser General Public License
* (version 2.1 or later). See the COPYING file in this distribution.
@ -571,9 +571,7 @@ public class GearyController : Geary.BaseObject {
try {
yield this.account_manager.expunge_accounts(this.open_cancellable);
} catch (GLib.Error err) {
report_problem(
new Geary.ProblemReport(Geary.ProblemType.GENERIC_ERROR, err)
);
report_problem(new Geary.ProblemReport(err));
}
}
@ -761,13 +759,7 @@ public class GearyController : Geary.BaseObject {
// Bail out right away, but probably should be opening
// the GOA control panel.
handled = false;
report_problem(
new Geary.AccountProblemReport(
Geary.ProblemType.GENERIC_ERROR,
account,
err
)
);
report_problem(new Geary.AccountProblemReport(account, err));
}
context.authentication_prompting = false;
} else {
@ -815,12 +807,7 @@ public class GearyController : Geary.BaseObject {
// all good
} catch (GLib.Error err) {
report_problem(
new Geary.ServiceProblemReport(
Geary.ProblemType.GENERIC_ERROR,
account,
service,
err
)
new Geary.ServiceProblemReport(account, service, err)
);
}
@ -839,12 +826,7 @@ public class GearyController : Geary.BaseObject {
);
} catch (GLib.Error err) {
report_problem(
new Geary.ServiceProblemReport(
Geary.ProblemType.GENERIC_ERROR,
account,
service,
err
)
new Geary.ServiceProblemReport(account, service, err)
);
}
} else {
@ -882,7 +864,6 @@ public class GearyController : Geary.BaseObject {
context.tls_validation_failed = false;
report_problem(
new Geary.ServiceProblemReport(
Geary.ProblemType.UNTRUSTED,
context.account.information,
service,
err
@ -939,7 +920,6 @@ public class GearyController : Geary.BaseObject {
if (!retry) {
report_problem(
new Geary.AccountProblemReport(
Geary.ProblemType.GENERIC_ERROR,
account.information,
open_err
)
@ -1879,9 +1859,7 @@ public class GearyController : Geary.BaseObject {
"Error opening attachment file \"%s\": %s",
attachment.file.get_uri(), err.message
);
report_problem(
new Geary.ProblemReport(Geary.ProblemType.GENERIC_ERROR, err)
);
report_problem(new Geary.ProblemReport(err));
}
yield this.prompt_save_buffer(display_name, content, cancellable);
@ -1914,11 +1892,7 @@ public class GearyController : Geary.BaseObject {
"Error opening attachment files \"%s\": %s",
attachment.file.get_uri(), err.message
);
report_problem(
new Geary.ProblemReport(
Geary.ProblemType.GENERIC_ERROR, err
)
);
report_problem(new Geary.ProblemReport(err));
}
if (content != null &&
@ -2017,9 +1991,7 @@ public class GearyController : Geary.BaseObject {
"Error writing buffer \"%s\": %s",
dest.get_uri(), err.message
);
report_problem(
new Geary.ProblemReport(Geary.ProblemType.GENERIC_ERROR, err)
);
report_problem(new Geary.ProblemReport(err));
}
}
@ -2897,11 +2869,7 @@ public class GearyController : Geary.BaseObject {
try {
this.application.engine.add_account(added);
} catch (GLib.Error err) {
report_problem(
new Geary.AccountProblemReport(
Geary.ProblemType.GENERIC_ERROR, added, err
)
);
report_problem(new Geary.AccountProblemReport(added, err));
}
}
}
@ -2914,11 +2882,7 @@ public class GearyController : Geary.BaseObject {
try {
this.application.engine.add_account(changed);
} catch (GLib.Error err) {
report_problem(
new Geary.AccountProblemReport(
Geary.ProblemType.GENERIC_ERROR, changed, err
)
);
report_problem(new Geary.AccountProblemReport(changed, err));
}
}
break;
@ -2934,11 +2898,7 @@ public class GearyController : Geary.BaseObject {
this.application.engine.remove_account(changed);
} catch (GLib.Error err) {
report_problem(
new Geary.AccountProblemReport(
Geary.ProblemType.GENERIC_ERROR,
changed,
err
)
new Geary.AccountProblemReport(changed, err)
);
}
}
@ -2960,11 +2920,7 @@ public class GearyController : Geary.BaseObject {
debug("%s: Account removed from engine", removed.id);
} catch (GLib.Error err) {
report_problem(
new Geary.AccountProblemReport(
Geary.ProblemType.GENERIC_ERROR,
removed,
err
)
new Geary.AccountProblemReport(removed, err)
);
}
}
@ -3074,24 +3030,16 @@ public class GearyController : Geary.BaseObject {
}
private void on_scan_error(Geary.App.ConversationMonitor monitor, Error err) {
// XXX determine the problem better here
Geary.AccountInformation account =
monitor.base_folder.account.information;
report_problem(
new Geary.ServiceProblemReport(
Geary.ProblemType.GENERIC_ERROR,
account,
account.incoming,
err
)
new Geary.ServiceProblemReport(account, account.incoming, err)
);
}
private void on_email_load_error(ConversationEmail view, GLib.Error err) {
// XXX determine the problem better here
report_problem(
new Geary.ServiceProblemReport(
Geary.ProblemType.GENERIC_ERROR,
this.current_account.information,
this.current_account.information.incoming,
err

View file

@ -39,135 +39,50 @@ public class MainWindowInfoBar : Gtk.InfoBar {
if (report is Geary.ServiceProblemReport) {
Geary.ServiceProblemReport service_report = (Geary.ServiceProblemReport) report;
string account = service_report.account.display_name;
string server = service_report.service.host;
if (report.problem_type == Geary.ProblemType.CONNECTION_ERROR &&
service_report.service.protocol == Geary.Protocol.IMAP) {
// Translators: String substitution is the account name
title = _("Problem connecting to incoming server for %s".printf(account));
// Translators: String substitution is the server name
descr = _("Could not connect to %s, check your Internet access and the server name and try again").printf(server);
if (service_report.service.protocol == Geary.Protocol.IMAP) {
// Translators: Info bar title for an incoming account
// problem. String substitution is the account name
title = _("A problem occurred checking email for %s").printf(account);
// Translators: Info bar sub-title for an incoming account
// problem.
descr = _("Email will not be received until re-connected");
// Translators: Tooltip label for Retry button
retry = _("Try reconnecting");
} else if (report.problem_type == Geary.ProblemType.CONNECTION_ERROR &&
service_report.service.protocol == Geary.Protocol.SMTP) {
// Translators: String substitution is the account name
title = _("Problem connecting to outgoing server for %s".printf(account));
// Translators: String substitution is the server name
descr = _("Could not connect to %s, check your Internet access and the server name and try again").printf(server);
// Translators: Tooltip label for Retry button
retry = _("Try reconnecting");
} else if (report.problem_type == Geary.ProblemType.NETWORK_ERROR &&
service_report.service.protocol == Geary.Protocol.IMAP) {
// Translators: String substitution is the account name
title = _("Problem communicating with incoming server for %s").printf(account);
// Translators: String substitution is the server name
descr = _("Network error talking to %s, check your Internet access and try again").printf(server);
// Translators: Tooltip label for Retry button
retry = _("Try reconnecting");
} else if (report.problem_type == Geary.ProblemType.NETWORK_ERROR &&
service_report.service.protocol == Geary.Protocol.SMTP) {
// Translators: String substitution is the account name
title = _("Problem communicating with outgoing mail server");
// Translators: String substitution is the server name
descr = _("Network error talking to %s, check your Internet access and try again").printf(server);
// Translators: Tooltip label for Retry button
retry = _("Try reconnecting");
} else if (report.problem_type == Geary.ProblemType.SERVER_ERROR &&
service_report.service.protocol == Geary.Protocol.IMAP) {
// Translators: String substitution is the account name
title = _("Problem communicating with incoming server for %s").printf(account);
// Translators: String substitution is the server name
descr = _("Geary did not understand a message from %s or vice versa, please file a bug report").printf(server);
// Translators: Tooltip label for Retry button
retry = _("Try reconnecting");
} else if (report.problem_type == Geary.ProblemType.SERVER_ERROR &&
service_report.service.protocol == Geary.Protocol.SMTP) {
title = _("Problem communicating with outgoing mail server");
// Translators: First string substitution is the server
// name, second is the account name
descr = _("Could not communicate with %s for %s, check the server name and try again in a moment").printf(server, account);
// Translators: Tooltip label for Retry button
retry = _("Try reconnecting");
} else if (report.problem_type == Geary.ProblemType.AUTHENTICATION &&
service_report.service.protocol == Geary.Protocol.IMAP) {
// Translators: String substitution is the account name
title = _("Incoming mail server password required for %s").printf(account);
descr = _("Messages cannot be received without the correct password.");
// Translators: Tooltip label for Retry button
retry = _("Retry receiving email, you will be prompted for a password");
} else if (report.problem_type == Geary.ProblemType.AUTHENTICATION &&
service_report.service.protocol == Geary.Protocol.SMTP) {
// Translators: String substitution is the account name
title = _("Outgoing mail server password required for %s").printf(account);
descr = _("Messages cannot be sent without the correct password.");
// Translators: Tooltip label for Retry button
retry = _("Retry sending queued messages, you will be prompted for a password");
} else if (report.problem_type == Geary.ProblemType.UNTRUSTED &&
service_report.service.protocol == Geary.Protocol.IMAP) {
// Translators: String substitution is the account name
title = _("Incoming mail server security is not trusted for %s").printf(account);
descr = _("Messages will not be received until checked.");
// Translators: Tooltip label for Retry button
retry = _("Check security details");
} else if (report.problem_type == Geary.ProblemType.UNTRUSTED &&
service_report.service.protocol == Geary.Protocol.SMTP) {
// Translators: String substitution is the account name
title = _("Outgoing mail server security is not trusted for %s").printf(account);
descr = _("Messages cannot be sent until checked.");
// Translators: Tooltip label for Retry button
retry = _("Check security details");
} else if (report.problem_type == Geary.ProblemType.GENERIC_ERROR &&
service_report.service.protocol == Geary.Protocol.IMAP) {
// Translators: String substitution is the account name
title = _("A problem occurred checking mail for %s").printf(account);
descr = _("Something went wrong, please file a bug report if the problem persists");
// Translators: Tooltip label for Retry button
retry = _("Try reconnecting");
} else if (report.problem_type == Geary.ProblemType.GENERIC_ERROR &&
service_report.service.protocol == Geary.Protocol.SMTP) {
// Translators: String substitution is the account name
title = _("A problem occurred sending mail for %s").printf(account);
descr = _("Something went wrong, please file a bug report if the problem persists");
} else if (service_report.service.protocol == Geary.Protocol.SMTP) {
// Translators: Info bar title for an outgoing account
// problem. String substitution is the account name
title = _("A problem occurred sending email for %s").printf(account);
// Translators: Info bar sub-title for an outgoing
// account problem.
descr = _("Email will not be sent until re-connected");
// Translators: Tooltip label for Retry button
retry = _("Retry sending queued messages");
} else {
debug("Un-handled service problem report: %s".printf(report.to_string()));
show_generic = true;
}
} else if (report is Geary.AccountProblemReport) {
Geary.AccountProblemReport account_report = (Geary.AccountProblemReport) report;
string account = account_report.account.display_name;
if (report.problem_type == Geary.ProblemType.DATABASE_FAILURE) {
type = Gtk.MessageType.ERROR;
title = _("A database problem has occurred");
// Translators: String substitution is the account name
descr = _("Messages for %s must be downloaded again.").printf(account);
show_close = true;
} else {
debug("Un-handled account problem report: %s".printf(report.to_string()));
show_generic = true;
}
// Translators: Info bar title for a generic account
// problem. String substitution is the account name
title = _("A problem occurred with account %s").printf(account);
// Translators: Info bar sub-title for a generic account
// problem.
descr = _("Something went wrong, please file a bug report if the problem persists");
} else {
debug("Un-handled generic problem report: %s".printf(report.to_string()));
show_generic = true;
}
if (show_generic) {
// Translators: Info bar title for a generic application
// problem.
title = _("Geary has encountered a problem");
// Translators: Info bar sub-title for a generic
// application problem.
descr = _("Please check the technical details and report the problem if it persists.");
show_close = true;
}
@ -176,11 +91,17 @@ public class MainWindowInfoBar : Gtk.InfoBar {
this.report = report;
if (this.report.error != null) {
// Translators: Button label for viewing technical details
// for a problem report.
Gtk.Button details = add_button(_("_Details"), ResponseType.DETAILS);
// Translators: Tooltip for viewing technical details for
// a problem report.
details.tooltip_text = _("View technical details about the error");
}
if (retry != null) {
// Translators: Button label for retrying a server
// connection
Gtk.Button retry_btn = add_button(_("_Retry"), ResponseType.RETRY);
retry_btn.tooltip_text = retry;
}

View file

@ -532,16 +532,15 @@ public abstract class Geary.Account : BaseObject {
/**
* Fires a {@link report_problem} signal for this account.
*/
protected virtual void notify_account_problem(ProblemType type, Error? err) {
report_problem(new AccountProblemReport(type, this.information, err));
protected virtual void notify_account_problem(Error? err) {
report_problem(new AccountProblemReport(this.information, err));
}
/** Fires a {@link report_problem} signal for a service for this account. */
protected virtual void notify_service_problem(ProblemType type,
ServiceInformation service,
protected virtual void notify_service_problem(ServiceInformation service,
Error? err) {
report_problem(
new ServiceProblemReport(type, this.information, service, err)
new ServiceProblemReport(this.information, service, err)
);
}

View file

@ -1,74 +1,22 @@
/*
* Copyright 2016 Software Freedom Conservancy Inc.
* Copyright 2017-2018 Michael Gratton <mike@vee.net>
* Copyright 2017-2019 Michael Gratton <mike@vee.net>
*
* This software is licensed under the GNU Lesser General Public License
* (version 2.1 or later). See the COPYING file in this distribution.
*/
/** Describes available problem types. */
public enum Geary.ProblemType {
/** Indicates an engine problem not covered by one of the other types. */
GENERIC_ERROR,
/** Indicates an error opening, using or closing the account database. */
DATABASE_FAILURE,
/** Indicates a problem establishing a connection. */
CONNECTION_ERROR,
/** Indicates a problem caused by a network operation. */
NETWORK_ERROR,
/** Indicates a non-network related server error. */
SERVER_ERROR,
/** Indicates credentials supplied for authentication were rejected. */
AUTHENTICATION,
/** Indicates a remote TLS certificate failed validation. */
UNTRUSTED,
/** Indicates an outgoing message was sent, but not saved. */
SEND_EMAIL_SAVE_FAILED;
/** Determines the appropriate problem type for an IOError. */
public static ProblemType for_ioerror(IOError error) {
if (error is IOError.CONNECTION_REFUSED ||
error is IOError.HOST_NOT_FOUND ||
error is IOError.HOST_UNREACHABLE ||
error is IOError.NETWORK_UNREACHABLE) {
return ProblemType.CONNECTION_ERROR;
}
if (error is IOError.CONNECTION_CLOSED ||
error is IOError.NOT_CONNECTED) {
return ProblemType.NETWORK_ERROR;
}
return ProblemType.GENERIC_ERROR;
}
}
/**
* Describes a error that the engine encountered, for reporting to the client.
*/
public class Geary.ProblemReport : Object {
/** Describes the type of being reported. */
public ProblemType problem_type { get; private set; }
/** The exception caused the problem, if any. */
public ErrorContext? error { get; private set; default = null; }
public ProblemReport(ProblemType type, Error? error) {
this.problem_type = type;
public ProblemReport(Error? error) {
if (error != null) {
this.error = new ErrorContext(error);
}
@ -76,8 +24,7 @@ public class Geary.ProblemReport : Object {
/** Returns a string representation of the report, for debugging only. */
public string to_string() {
return "%s: %s".printf(
this.problem_type.to_string(),
return "%s".printf(
this.error != null
? this.error.format_full_error()
: "no error reported"
@ -96,8 +43,8 @@ public class Geary.AccountProblemReport : ProblemReport {
public AccountInformation account { get; private set; }
public AccountProblemReport(ProblemType type, AccountInformation account, Error? error) {
base(type, error);
public AccountProblemReport(AccountInformation account, Error? error) {
base(error);
this.account = account;
}
@ -118,20 +65,18 @@ public class Geary.ServiceProblemReport : AccountProblemReport {
public ServiceInformation service { get; private set; }
public ServiceProblemReport(ProblemType type,
AccountInformation account,
public ServiceProblemReport(AccountInformation account,
ServiceInformation service,
Error? error) {
base(type, account, error);
base(account, error);
this.service = service;
}
/** Returns a string representation of the report, for debugging only. */
public new string to_string() {
return "%s: %s: %s: %s".printf(
return "%s: %s: %s".printf(
this.account.id,
this.service.protocol.to_string(),
this.problem_type.to_string(),
this.error != null
? this.error.format_full_error()
: "no error reported"

View file

@ -137,7 +137,6 @@ private class Geary.ImapEngine.RefreshFolderSync : FolderOperation {
} catch (GLib.Error err) {
this.account.report_problem(
new ServiceProblemReport(
ProblemType.GENERIC_ERROR,
this.account.information,
this.account.information.outgoing,
err

View file

@ -999,18 +999,7 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
}
private void on_operation_error(AccountOperation op, Error error) {
if (error is ImapError) {
notify_service_problem(
ProblemType.SERVER_ERROR, this.information.incoming, error
);
} else if (error is IOError) {
// IOErrors could be network related or disk related, need
// to work out the difference and send a service problem
// if definitely network related
notify_account_problem(ProblemType.for_ioerror((IOError) error), error);
} else {
notify_account_problem(ProblemType.GENERIC_ERROR, error);
}
notify_service_problem(this.information.incoming, error);
}
private void on_imap_status_notify() {