From 5877f228dd6138384b2958b51d680754b7197080 Mon Sep 17 00:00:00 2001 From: Chralu Date: Thu, 20 Jun 2024 11:16:56 +0200 Subject: [PATCH] fix(rpc): Exception are transformed to rpc Failures. --- lib/domain/rpc/command_dispatcher.dart | 2 +- lib/infrastructure/rpc/dto/rpc_command_handler.dart | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/domain/rpc/command_dispatcher.dart b/lib/domain/rpc/command_dispatcher.dart index acd2a101d..ba7c84573 100644 --- a/lib/domain/rpc/command_dispatcher.dart +++ b/lib/domain/rpc/command_dispatcher.dart @@ -145,7 +145,7 @@ class CommandDispatcher { .handle(command.command) .then( command.completer.complete, - onError: (error) => command.completer.complete(Result.failure(error)), + onError: command.completer.completeError, ) .whenComplete(_process); } diff --git a/lib/infrastructure/rpc/dto/rpc_command_handler.dart b/lib/infrastructure/rpc/dto/rpc_command_handler.dart index 0dd003656..3c5426e5f 100644 --- a/lib/infrastructure/rpc/dto/rpc_command_handler.dart +++ b/lib/infrastructure/rpc/dto/rpc_command_handler.dart @@ -35,6 +35,9 @@ abstract class RPCCommandHandler { } on TypeError catch (e, stack) { _logger.severe('Invalid data', e, stack); return const Result.failure(awc.Failure.invalidParams); + } catch (e, stack) { + _logger.severe('Command failed', e, stack); + return const Result.failure(awc.Failure.other); } } }