Skip to content

Conversation

@grypez
Copy link
Contributor

@grypez grypez commented Sep 28, 2024

It seems reasonable to me that any reply except 'pong' could be an error. Once we get custom error classes we could set the ErrorType to the appropriate union for each CommandReply element.

Changes

@ocap/kernel

  • Realizes CommandReply as a union of the new CommandReplyLike type
type CommandReplyLike<
  Method extends CommandMethod,
  Data extends CommandParams,
  ErrorType extends Error = never,
> = {
  method: Method;
  params: Data|ErrorType;
};
  • Permits CommandMethod.KVGet to return an Error as its params

@ocap/extension

  • Introduces an asError routine to cast problems to Errors (reference)

@grypez grypez requested a review from a team as a code owner September 28, 2024 11:23
@grypez grypez force-pushed the grypez/command-replies-can-return-errors branch from b77d4bd to e886d04 Compare September 28, 2024 11:26
Copy link
Contributor

@FUDCo FUDCo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooh ooh!

@grypez grypez force-pushed the grypez/command-replies-can-return-errors branch from e886d04 to 7ecf5c0 Compare September 30, 2024 18:07
@grypez grypez merged commit 414cbac into main Sep 30, 2024
@grypez grypez deleted the grypez/command-replies-can-return-errors branch September 30, 2024 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants