2
* Copyright 2016 Software Freedom Conservancy Inc.
3
* Copyright 2017-2018 Michael Gratton <mike@vee.net>
5
* This software is licensed under the GNU Lesser General Public License
6
* (version 2.1 or later). See the COPYING file in this distribution.
9
/** Describes available problem types. */
10
public enum Geary.ProblemType {
13
/** Indicates an engine problem not covered by one of the other types. */
16
/** Indicates an error opening, using or closing the account database. */
19
/** Indicates a problem establishing a connection. */
22
/** Indicates a problem caused by a network operation. */
25
/** Indicates a non-network related server error. */
28
/** Indicates credentials supplied for authentication were rejected. */
31
/** Indicates a remote TLS certificate failed validation. */
34
/** Indicates an outgoing message was sent, but not saved. */
35
SEND_EMAIL_SAVE_FAILED;
38
/** Determines the appropriate problem type for an IOError. */
39
public static ProblemType for_ioerror(IOError error) {
40
if (error is IOError.CONNECTION_REFUSED ||
41
error is IOError.HOST_NOT_FOUND ||
42
error is IOError.HOST_UNREACHABLE ||
43
error is IOError.NETWORK_UNREACHABLE) {
44
return ProblemType.CONNECTION_ERROR;
47
if (error is IOError.CONNECTION_CLOSED ||
48
error is IOError.NOT_CONNECTED) {
49
return ProblemType.NETWORK_ERROR;
52
return ProblemType.GENERIC_ERROR;
58
* Describes a error that the engine encountered, for reporting to the client.
60
public class Geary.ProblemReport : Object {
63
/** Describes the type of being reported. */
64
public ProblemType problem_type { get; private set; }
66
/** The exception caused the problem, if any. */
67
public ErrorContext? error { get; private set; default = null; }
70
public ProblemReport(ProblemType type, Error? error) {
71
this.problem_type = type;
73
this.error = new ErrorContext(error);
77
/** Returns a string representation of the report, for debugging only. */
78
public string to_string() {
79
return "%s: %s".printf(
80
this.problem_type.to_string(),
82
? this.error.format_full_error()
90
* Describes an account-related error that the engine encountered.
92
public class Geary.AccountProblemReport : ProblemReport {
95
/** The account related to the problem report. */
96
public AccountInformation account { get; private set; }
99
public AccountProblemReport(ProblemType type, AccountInformation account, Error? error) {
101
this.account = account;
104
/** Returns a string representation of the report, for debugging only. */
105
public new string to_string() {
106
return "%s: %s".printf(this.account.id, base.to_string());
112
* Describes a service-related error that the engine encountered.
114
public class Geary.ServiceProblemReport : AccountProblemReport {
117
/** The service related to the problem report. */
118
public ServiceInformation service { get; private set; }
121
public ServiceProblemReport(ProblemType type,
122
AccountInformation account,
123
ServiceInformation service,
125
base(type, account, error);
126
this.service = service;
129
/** Returns a string representation of the report, for debugging only. */
130
public new string to_string() {
131
return "%s: %s: %s: %s".printf(
133
this.service.protocol.to_string(),
134
this.problem_type.to_string(),
136
? this.error.format_full_error()
137
: "no error reported"