Fix forward recipients error handling
This commit is contained in:
@@ -43,7 +43,10 @@ class ForwardingAPI with HandleSetErrorMixin {
|
||||
return tMailForwardResult;
|
||||
}
|
||||
|
||||
Future<TMailForward> updateForward(AccountId accountId, TMailForward forward) async {
|
||||
Future<(TMailForward, SetMethodException?)> updateForward(
|
||||
AccountId accountId,
|
||||
TMailForward forward,
|
||||
) async {
|
||||
log('ForwardingAPI::updateForward: ${forward.toJson()}');
|
||||
final setForwardMethod = SetForwardMethod(accountId)
|
||||
..addUpdatesSingleton({
|
||||
@@ -69,14 +72,9 @@ class ForwardingAPI with HandleSetErrorMixin {
|
||||
);
|
||||
|
||||
final mapErrors = handleSetResponse([setForwardResponse]);
|
||||
if (mapErrors.isNotEmpty) {
|
||||
throw SetMethodException(mapErrors);
|
||||
}
|
||||
|
||||
final updatedForward = setForwardResponse?.updated;
|
||||
if (updatedForward?.isNotEmpty != true) {
|
||||
throw UpdateForwardException();
|
||||
}
|
||||
final methodException = mapErrors.isNotEmpty
|
||||
? SetMethodException(mapErrors)
|
||||
: null;
|
||||
|
||||
final getForwardResponse = response.parse<GetForwardResponse>(
|
||||
getForwardInvocation.methodCallId,
|
||||
@@ -84,10 +82,10 @@ class ForwardingAPI with HandleSetErrorMixin {
|
||||
);
|
||||
|
||||
final newForward = getForwardResponse?.list.firstOrNull;
|
||||
if (newForward == null) {
|
||||
throw NotFoundForwardException();
|
||||
if (newForward != null) {
|
||||
return (newForward, methodException);
|
||||
}
|
||||
|
||||
return newForward;
|
||||
throw methodException ?? NotFoundForwardException();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user