Struct SerializationResult
Represents the outcome of a serialization or deserialization operation that does not produce a return value (for example, serializing directly to a stream). Carries either a success flag or an error message and optional exception, without any associated payload.
Inherited Members
Namespace: Scylla.Core.Util.Serialization
Assembly: ScyllaCore.dll
Syntax
public readonly struct SerializationResult
Remarks
SerializationResult and SerializationResult<T> are the primary mechanism by which ScyllaSerialization communicates operation outcomes to callers without throwing exceptions. Instead of propagating a SerializationException out of the top-level API, the exception is caught internally and encoded into a failed result.
Always check IsSuccess (or equivalently IsFailure)
before treating the operation as completed. A failed result with a non-null
Exception indicates an unexpected lower-level failure; a failed
result where Exception is null indicates a structured
serialization error with a known message.
Use Success() and Failure(string, Exception) to construct instances. The struct is immutable once created.
Properties
ErrorMessage
Gets the human-readable error message describing the failure, or null when
the operation succeeded. The message is sourced from the caught
SerializationException.Message or from the string passed to
Failure(string, Exception). A fallback of
"Unknown error" is used when a null message is provided.
Declaration
public string ErrorMessage { get; }
Property Value
| Type | Description |
|---|---|
| string | A non-null, non-empty string when IsFailure is |
Exception
Gets the exception that caused the operation to fail, if one was captured. For
structured serialization failures (e.g., exceeding max depth) this may be
null even when IsFailure is true, because the
error was encoded as a message rather than an exception.
Declaration
public Exception Exception { get; }
Property Value
| Type | Description |
|---|---|
| Exception | The underlying Exception, or |
IsFailure
Gets a value indicating whether the serialization or deserialization operation failed. This is the logical complement of IsSuccess.
Declaration
public bool IsFailure { get; }
Property Value
| Type | Description |
|---|---|
| bool |
|
IsSuccess
Gets a value indicating whether the serialization or deserialization operation completed without errors.
Declaration
public bool IsSuccess { get; }
Property Value
| Type | Description |
|---|---|
| bool |
|
Methods
Failure(string, Exception)
Creates a SerializationResult that represents a failed operation.
Declaration
public static SerializationResult Failure(string errorMessage, Exception exception = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | errorMessage | A message describing the failure. If |
| Exception | exception | The exception that caused the failure, or |
Returns
| Type | Description |
|---|---|
| SerializationResult | A result with IsSuccess set to |
Success()
Creates a SerializationResult that represents a successful operation.
Declaration
public static SerializationResult Success()
Returns
| Type | Description |
|---|---|
| SerializationResult | A result with IsSuccess set to |