Skip to content

Add a SpacetimeDBException to C# SDK to aid in debugging#3386

Merged
rekhoff merged 23 commits intomasterfrom
rekhoff/custom-csharp-sdk-exceptions
Oct 24, 2025
Merged

Add a SpacetimeDBException to C# SDK to aid in debugging#3386
rekhoff merged 23 commits intomasterfrom
rekhoff/custom-csharp-sdk-exceptions

Conversation

@rekhoff
Copy link
Contributor

@rekhoff rekhoff commented Oct 8, 2025

Description of Changes

This implements a fix to an issue with debugging using the C# SDK, by adding new exception types:

  • SpacetimeDBException,
  • SpacetimeDBArgumentException,
  • SpacetimeDBEmptyReducerNameException

Additional, regenerating bindings will now allow clients to report an SpacetimeDBEmptyReducerNameException rather than an ArgumentOutOfRangeException when the client receives an empty reducer name from the server.

An example of the generated code currently, that results in the exception:

var reducer => throw new ArgumentOutOfRangeException("Reducer", $"Unknown reducer {reducer}")

Note: Normally this is not an issue for a client, because the SpacetimeDBEmptyReducerNameException would be caught by the Try/Catch statement, but a debugger will still catch the exception and halt operation. This can be annoying to a developer when debugging.

By separating out the exception into a custom Exception type, we allow a developer to flag the new exception type as something it can ignore, without ignoring other relevant exceptions.

API and ABI breaking changes

Not a breaking change.
Clients will need to regenerate bindings to get the new exceptions

Expected complexity level and risk

1

Testing

  • Tested regenerating bindings and confirmed intended output.
  • Tested debugging and receiving SpacetimeDBEmptyReducerNameException when expected.

@rekhoff rekhoff requested a review from gefjon October 8, 2025 18:57
@rekhoff rekhoff self-assigned this Oct 8, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Oct 8, 2025

Some missing or dangling .meta found. Fix commits are needed.

Status File
Not committed src/Exceptions.cs.meta

@rekhoff rekhoff marked this pull request as ready for review October 20, 2025 20:48
@bfops bfops changed the base branch from master to bfops/fix-csharp-quickstart-smoketest October 23, 2025 18:35
bfops added 2 commits October 23, 2025 12:52
…'origin/master' into rekhoff/custom-csharp-sdk-exceptions
…'origin/master' into rekhoff/custom-csharp-sdk-exceptions
github-merge-queue bot pushed a commit that referenced this pull request Oct 23, 2025
# Description of Changes

The quickstart smoketest was not correctly fudging our NuGet
dependencies to use the local versions of the packages, so it was
pulling them from NuGet. This ended up causing issues when we tried to
modify local packages and then use them in a way that affected the
quickstart (e.g.
#3386).

We had a few issues: we weren't ensuring that the local packages were
built, we weren't using the right directory for those packages, and we
weren't adding a "package source mapping" that forced those packages to
be used from the local directory.

# API and ABI breaking changes

None. CI-only.

# Expected complexity level and risk

2

# Testing

- [x] CI passes when
#3386 is merged
together with this PR (it wasn't before).

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
…'origin/master' into rekhoff/custom-csharp-sdk-exceptions
…'origin/master' into rekhoff/custom-csharp-sdk-exceptions
@bfops bfops changed the base branch from bfops/fix-csharp-quickstart-smoketest to master October 23, 2025 20:28
@rekhoff rekhoff requested a review from jdetter October 23, 2025 20:35
Copy link
Collaborator

@jdetter jdetter left a comment

Choose a reason for hiding this comment

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

Haven't tested this myself but I was involved in the early testing of this PR and also this is quite simple. LGTM 👍

@rekhoff rekhoff added this pull request to the merge queue Oct 24, 2025
Merged via the queue into master with commit 023a7d3 Oct 24, 2025
21 of 26 checks passed
bfops added a commit that referenced this pull request Nov 3, 2025
# Description of Changes

This implements a fix to an issue with debugging using the C# SDK, by
adding new exception types:
* `SpacetimeDBException`, 
* `SpacetimeDBArgumentException`,
* `SpacetimeDBEmptyReducerNameException`

Additional, regenerating bindings will now allow clients to report an
`SpacetimeDBEmptyReducerNameException` rather than an
`ArgumentOutOfRangeException` when the client receives an empty reducer
name from the server.

An example of the generated code currently, that results in the
exception:
https://github.com/clockworklabs/SpacetimeDB/blob/544e2edc2d1f7d1dd118832a815b6dbd7a6c1d82/sdks/csharp/examples~/quickstart-chat/client/module_bindings/SpacetimeDBClient.g.cs#L475

Note: Normally this is not an issue for a client, because the
`SpacetimeDBEmptyReducerNameException` would be caught by the
[Try/Catch](https://github.com/clockworklabs/SpacetimeDB/blob/9f59118e24449cdd2d3e182bd44fdb26078e921b/sdks/csharp/src/SpacetimeDBClient.cs#L421C25-L421C42)
statement, but a debugger will still catch the exception and halt
operation. This can be annoying to a developer when debugging.

By separating out the exception into a custom `Exception` type, we allow
a developer to flag the new exception type as something it can ignore,
without ignoring other relevant exceptions.

# API and ABI breaking changes

Not a breaking change.
Clients will need to regenerate bindings to get the new exceptions

# Expected complexity level and risk

1

# Testing

- [X] Tested regenerating bindings and confirmed intended output.
- [X] Tested debugging and receiving
`SpacetimeDBEmptyReducerNameException` when expected.

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
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