Skip to content

Commit

Permalink
Fixed the exception deserialization issue, close #105.
Browse files Browse the repository at this point in the history
  • Loading branch information
yallie committed Dec 10, 2024
1 parent d916926 commit f1387ae
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 88 deletions.
9 changes: 6 additions & 3 deletions CoreRemoting.Tests/RpcTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -565,14 +565,17 @@ void AfterCall(object sender, ServerRpcContext ctx)

client.Connect();

var dbError = "23503: delete from table 'clients' violates " +
"foreign key constraint 'order_client_fk' on table 'orders'";

// simulate a database error on the server-side
var proxy = client.CreateProxy<ITestService>();
var ex = Assert.Throws<RemoteInvocationException>(() =>
proxy.Error("23503: delete from table 'clients' violates foreign key constraint 'order_client_fk' on table 'orders'"))
.GetInnermostException();
var ex = Assert.Throws<Exception>(() => proxy.Error(dbError));

Assert.NotNull(ex);
Assert.Equal("Deleting clients is not allowed.", ex.Message);
Assert.NotNull(ex.InnerException);
Assert.Equal(dbError, ex.InnerException.Message);
}
finally
{
Expand Down
2 changes: 1 addition & 1 deletion CoreRemoting/ClientRpcContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ internal ClientRpcContext()
/// <summary>
/// Gets or sets an exception that describes an error that occurred on server side RPC invocation.
/// </summary>
public RemoteInvocationException RemoteException { get; set; }
public Exception RemoteException { get; set; }

/// <summary>
/// Gets a wait handle that is set, when the response of this RPC call is received from server.
Expand Down
Loading

0 comments on commit f1387ae

Please sign in to comment.