Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception type mismatch #105

Closed
yallie opened this issue Dec 10, 2024 · 0 comments
Closed

Exception type mismatch #105

yallie opened this issue Dec 10, 2024 · 0 comments

Comments

@yallie
Copy link
Collaborator

yallie commented Dec 10, 2024

Describe the bug
ServerRpcContext.Exception is of type Exception, but ClientRpcContext property is of RemoteInvocationException type.
If server-side AfterCall event handler wraps around the exception, client may not be able to receive it.

To Reproduce

// remote call results in a typical database error report:
// 23503: delete from table 'clients' violates foreign key constraint 'order_client_fk' on table 'orders'
proxy.DeleteRecord(clientId);

// server sets up a centralized exception logger and translator:
// real error report is logged somewhere, and friendly translation is sent to the client
server.AfterCall += (sender, ctx) =>
{
  // replace cryptic database error report with a user-readable error message
  if (ctx.Exception != null && ctx.Exception.Message.StartsWith("23503:"))
    ctx.Exception = new Exception("Deleting clients is not allowed.", ctx.Exception);
}

Expected behavior
The client should be able to get any exception from server as long as it is deserializable.

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

No branches or pull requests

1 participant