Skip to content

Commit

Permalink
fix(ferry): Cast ErrorTypedLink's forward response stream to TData/TVars
Browse files Browse the repository at this point in the history
In the ErrorTypedLink, the response stream recieved via the forward
function is not type-constrained, thus cast it to be of the generic
types TData and TVars.

Signed-off-by: Jim Gerth <[email protected]>
  • Loading branch information
jimgerth committed Nov 18, 2024
1 parent e6300d7 commit 7b72f20
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions packages/ferry/lib/src/error_typed_link.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,21 @@ class ErrorTypedLink extends TypedLink {
forward,
]) {
try {
return forward!(operationRequest).transform(
StreamTransformer.fromHandlers(
handleError: (error, stackTrace, sink) => sink.add(
OperationResponse(
operationRequest: operationRequest,
linkException: error is LinkException
? error
: TypedLinkException(error, stackTrace),
dataSource: DataSource.None,
return forward!(operationRequest)
.cast<OperationResponse<TData, TVars>>()
.transform(
StreamTransformer.fromHandlers(
handleError: (error, stackTrace, sink) => sink.add(
OperationResponse(
operationRequest: operationRequest,
linkException: error is LinkException
? error
: TypedLinkException(error, stackTrace),
dataSource: DataSource.None,
),
),
),
),
),
);
);
} catch (error, stackTrace) {
return Stream.value(
OperationResponse(
Expand Down

0 comments on commit 7b72f20

Please sign in to comment.