Remove ProblemReport ProblemType enum altogether
It only has one value, so there's no point keeping it hanging around.
This commit is contained in:
parent
207eb07bae
commit
2f21298265
6 changed files with 30 additions and 121 deletions
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -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.GENERIC_ERROR,
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,35 +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 another type. */
|
||||
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);
|
||||
}
|
||||
|
|
@ -37,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"
|
||||
|
|
@ -57,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;
|
||||
}
|
||||
|
||||
|
|
@ -79,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"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -999,9 +999,7 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
|
|||
}
|
||||
|
||||
private void on_operation_error(AccountOperation op, Error error) {
|
||||
notify_service_problem(
|
||||
ProblemType.GENERIC_ERROR, this.information.incoming, error
|
||||
);
|
||||
notify_service_problem(this.information.incoming, error);
|
||||
}
|
||||
|
||||
private void on_imap_status_notify() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue