Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/bindings-csharp/Runtime/Internal/Module.cs
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,8 @@
}
catch (Exception e)
{
var error_str = e.ToString();
var error_str = e.Message ?? e.GetType().FullName;
var error_bytes = System.Text.Encoding.UTF8.GetBytes(error_str);

Check warning on line 316 in crates/bindings-csharp/Runtime/Internal/Module.cs

View workflow job for this annotation

GitHub Actions / Test Suite

Possible null reference argument for parameter 's' in 'byte[] Encoding.GetBytes(string s)'.

Check warning on line 316 in crates/bindings-csharp/Runtime/Internal/Module.cs

View workflow job for this annotation

GitHub Actions / unity-testsuite

Possible null reference argument for parameter 's' in 'byte[] Encoding.GetBytes(string s)'.

Check warning on line 316 in crates/bindings-csharp/Runtime/Internal/Module.cs

View workflow job for this annotation

GitHub Actions / csharp-testsuite

Possible null reference argument for parameter 's' in 'byte[] Encoding.GetBytes(string s)'.
error.Write(error_bytes);
return Errno.HOST_CALL_FAILURE;
}
Expand Down
15 changes: 14 additions & 1 deletion sdks/csharp/examples~/regression-tests/client/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

const string HOST = "http://localhost:3000";
const string DBNAME = "btree-repro";
const string THROW_ERROR_MESSAGE = "this is an error";

DbConnection ConnectToDB()
{
Expand Down Expand Up @@ -87,6 +88,7 @@ void OnConnected(DbConnection conn, Identity identity, string authToken)
{
Log.Info($"Got OnUnhandledReducerError: {exception}");
waiting--;
ValidateReducerErrorDoesNotContainStackTrace(exception);
ValidateBTreeIndexes(ctx);
ValidateNullableVecView(ctx);
};
Expand Down Expand Up @@ -167,6 +169,17 @@ void ValidateNullableVecView(
}
}

void ValidateReducerErrorDoesNotContainStackTrace(Exception exception)
{
Debug.Assert(
exception.Message == THROW_ERROR_MESSAGE,
$"Expected reducer error message '{THROW_ERROR_MESSAGE}', got '{exception.Message}'"
);
Debug.Assert(!exception.Message.Contains("\n"), "Reducer error message should not contain newline");
Debug.Assert(!exception.Message.Contains("\r"), "Reducer error message should not contain newline");
Debug.Assert(!exception.Message.Contains(" at "), "Reducer error message should not contain stack trace");
}

void OnSubscriptionApplied(SubscriptionEventContext context)
{
applied = true;
Expand All @@ -187,7 +200,7 @@ void OnSubscriptionApplied(SubscriptionEventContext context)

Log.Debug("Calling ThrowError");
waiting++;
context.Reducers.ThrowError("this is an error");
context.Reducers.ThrowError(THROW_ERROR_MESSAGE);

// RemoteQuery test
Log.Debug("Calling RemoteQuery");
Expand Down
Loading