Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions lib/jmap/core/error/method/error_method_response.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ abstract class ErrorMethodResponse extends MethodResponse {
static final accountNotFound = ErrorType("accountNotFound");
static final accountNotSupportedByMethod = ErrorType("accountNotSupportedByMethod");
static final accountReadOnly = ErrorType("accountReadOnly");
static final cannotCalculateChanges = ErrorType("cannotCalculateChanges");

final ErrorType type;
final String? description;
Expand Down Expand Up @@ -62,4 +63,20 @@ class AccountNotSupportedByMethod extends ErrorMethodResponse {

class AccountReadOnly extends ErrorMethodResponse {
AccountReadOnly({String? description}) : super(ErrorMethodResponse.accountReadOnly, description: description);
}

class CannotCalculateChangesMethodResponse extends ErrorMethodResponse {
CannotCalculateChangesMethodResponse({String? description}) : super(
ErrorMethodResponse.cannotCalculateChanges,
description: description);
}

class UndefinedErrorMethodResponse extends ErrorMethodResponse {
UndefinedErrorMethodResponse(
ErrorType errorType,
{String? description}
) : super(
errorType,
description: description
);
}
6 changes: 5 additions & 1 deletion lib/jmap/core/response/response_object.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,12 @@ class ResponseObject with EquatableMixin {
return ServerUnavailableMethodResponse(description: description);
} else if (errorType == ErrorMethodResponse.unknownMethod) {
return UnknownMethodResponse(description: description);
} else {
} else if (errorType == ErrorMethodResponse.serverFail) {
return ServerFailMethodResponse(description: description);
} else if (errorType == ErrorMethodResponse.cannotCalculateChanges) {
return CannotCalculateChangesMethodResponse(description: description);
} else {
return UndefinedErrorMethodResponse(errorType, description: description);
}
} catch (e) {
developer.log("_parsingErrorMethodResponse(): Exception $e");
Expand Down