-
Notifications
You must be signed in to change notification settings - Fork 1k
Add a SpacetimeDBException to C# SDK to aid in debugging #3386
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
Changes from all commits
4d2e4c1
5d01dcf
71ce0f4
70d69b7
cd3e433
0f35f58
49fb5cf
7a4c6f6
2bb5ede
dcbbb3e
f2b117f
98d37bf
57fecd1
a1c5445
78e6da9
dca3348
d560994
eff3cbc
98cd067
ecfa9e1
56f80ef
ce72b9c
0670e62
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,138 @@ | ||
| using System; | ||
| using System.Runtime.Serialization; | ||
|
|
||
| namespace SpacetimeDB | ||
| { | ||
| /// <summary> | ||
| /// The base class for all SpacetimeDB SDK exceptions. | ||
| /// This allows users to catch all SpacetimeDB-specific exceptions in one catch block | ||
| /// or configure their debugger to ignore them. | ||
| /// </summary> | ||
| [Serializable] | ||
| public class SpacetimeDBException : Exception | ||
| { | ||
| // Base HRESULT for SpacetimeDB exceptions (0x8A000000 is in the user-defined range) | ||
| private const int SPACETIMEDB_HRESULT_BASE = unchecked((int)0x8A000000); | ||
|
|
||
| // Specific HRESULTs for different exception types | ||
| public const int SPACETIMEDB_EMPTY_REDUCER_NAME = SPACETIMEDB_HRESULT_BASE + 1; | ||
|
|
||
| public SpacetimeDBException() | ||
| : base() | ||
| { | ||
| HResult = SPACETIMEDB_HRESULT_BASE; | ||
| } | ||
|
|
||
| public SpacetimeDBException(string? message) | ||
| : base(message) | ||
| { | ||
| HResult = SPACETIMEDB_HRESULT_BASE; | ||
| } | ||
|
|
||
| public SpacetimeDBException(string? message, Exception? innerException) | ||
| : base(message, innerException) | ||
| { | ||
| HResult = SPACETIMEDB_HRESULT_BASE; | ||
| } | ||
|
|
||
| protected SpacetimeDBException(SerializationInfo info, StreamingContext context) | ||
| : base(info, context) { } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// The exception that is thrown when one of the arguments provided to a method is not valid. | ||
| /// This is the base class for all SpacetimeDB argument exceptions. | ||
| /// </summary> | ||
| [Serializable] | ||
| public class SpacetimeDBArgumentException : SpacetimeDBException | ||
| { | ||
| private readonly string? _paramName; | ||
|
|
||
| public SpacetimeDBArgumentException() | ||
| : base("Value does not fall within the expected range.") { } | ||
|
|
||
| public SpacetimeDBArgumentException(string? message) | ||
| : base(message) { } | ||
|
|
||
| public SpacetimeDBArgumentException(string? message, Exception? innerException) | ||
| : base(message, innerException) { } | ||
|
|
||
| public SpacetimeDBArgumentException( | ||
| string? message, | ||
| string? paramName, | ||
| Exception? innerException | ||
| ) | ||
| : base(message, innerException) | ||
| { | ||
| _paramName = paramName; | ||
| } | ||
|
|
||
| public SpacetimeDBArgumentException(string? message, string? paramName) | ||
| : base(message) | ||
| { | ||
| _paramName = paramName; | ||
| } | ||
|
|
||
| protected SpacetimeDBArgumentException(SerializationInfo info, StreamingContext context) | ||
| : base(info, context) | ||
| { | ||
| _paramName = info.GetString("ParamName"); | ||
| } | ||
|
|
||
| public override void GetObjectData(SerializationInfo info, StreamingContext context) | ||
| { | ||
| base.GetObjectData(info, context); | ||
| info.AddValue("ParamName", _paramName, typeof(string)); | ||
| } | ||
|
|
||
| public virtual string? ParamName => _paramName; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// The exception that is thrown when an empty reducer name is received from the server. | ||
| /// This is a known condition that is handled internally by the SpacetimeDB client. | ||
| /// </summary> | ||
| [Serializable] | ||
| public class SpacetimeDBEmptyReducerNameException : SpacetimeDBArgumentException | ||
| { | ||
| public SpacetimeDBEmptyReducerNameException() | ||
| : base("Empty reducer name received from server", (string?)null) | ||
| { | ||
| HResult = SPACETIMEDB_EMPTY_REDUCER_NAME; | ||
| } | ||
|
|
||
| public SpacetimeDBEmptyReducerNameException(string? paramName) | ||
| : base("Empty reducer name received from server", paramName) | ||
| { | ||
| HResult = SPACETIMEDB_EMPTY_REDUCER_NAME; | ||
| } | ||
|
|
||
| public SpacetimeDBEmptyReducerNameException(string? message, string? paramName) | ||
| : base(message, paramName) | ||
| { | ||
| HResult = SPACETIMEDB_EMPTY_REDUCER_NAME; | ||
| } | ||
|
|
||
| public SpacetimeDBEmptyReducerNameException(string? message, Exception? innerException) | ||
| : base(message, null, innerException) | ||
| { | ||
| HResult = SPACETIMEDB_EMPTY_REDUCER_NAME; | ||
| } | ||
|
|
||
| public SpacetimeDBEmptyReducerNameException( | ||
| string? message, | ||
| string? paramName, | ||
| Exception? innerException | ||
| ) | ||
| : base(message, paramName, innerException) | ||
| { | ||
| HResult = SPACETIMEDB_EMPTY_REDUCER_NAME; | ||
| } | ||
|
|
||
| protected SpacetimeDBEmptyReducerNameException( | ||
| SerializationInfo info, | ||
| StreamingContext context | ||
| ) | ||
| : base(info, context) { } | ||
| } | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.