Skip to content

Commit 4ce1494

Browse files
committed
Add some error type for method response
1 parent ab07a8a commit 4ce1494

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

lib/jmap/core/error/method/error_method_response.dart

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ abstract class ErrorMethodResponse extends MethodResponse {
1414
static final accountNotFound = ErrorType("accountNotFound");
1515
static final accountNotSupportedByMethod = ErrorType("accountNotSupportedByMethod");
1616
static final accountReadOnly = ErrorType("accountReadOnly");
17+
static final cannotCalculateChanges = ErrorType("cannotCalculateChanges");
1718

1819
final ErrorType type;
1920
final String? description;
@@ -62,4 +63,20 @@ class AccountNotSupportedByMethod extends ErrorMethodResponse {
6263

6364
class AccountReadOnly extends ErrorMethodResponse {
6465
AccountReadOnly({String? description}) : super(ErrorMethodResponse.accountReadOnly, description: description);
66+
}
67+
68+
class CannotCalculateChangesMethodResponse extends ErrorMethodResponse {
69+
CannotCalculateChangesMethodResponse({String? description}) : super(
70+
ErrorMethodResponse.cannotCalculateChanges,
71+
description: description);
72+
}
73+
74+
class UndefinedErrorMethodResponse extends ErrorMethodResponse {
75+
UndefinedErrorMethodResponse(
76+
ErrorType errorType,
77+
{String? description}
78+
) : super(
79+
errorType,
80+
description: description
81+
);
6582
}

lib/jmap/core/response/response_object.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,12 @@ class ResponseObject with EquatableMixin {
6767
return ServerUnavailableMethodResponse(description: description);
6868
} else if (errorType == ErrorMethodResponse.unknownMethod) {
6969
return UnknownMethodResponse(description: description);
70-
} else {
70+
} else if (errorType == ErrorMethodResponse.serverFail) {
7171
return ServerFailMethodResponse(description: description);
72+
} else if (errorType == ErrorMethodResponse.cannotCalculateChanges) {
73+
return CannotCalculateChangesMethodResponse(description: description);
74+
} else {
75+
return UndefinedErrorMethodResponse(errorType, description: description);
7276
}
7377
} catch (e) {
7478
developer.log("_parsingErrorMethodResponse(): Exception $e");

0 commit comments

Comments
 (0)