Class JsonRpcError.ErrorDetail
- Namespace
- StreamJsonRpc.Protocol
- Assembly
- StreamJsonRpc.dll
Describes the error.
[DataContract]
[GenerateShape]
[MessagePackConverter(typeof(NerdbankMessagePackFormatter.JsonRpcErrorDetailConverter))]
public class JsonRpcError.ErrorDetail
- Inheritance
-
JsonRpcError.ErrorDetail
- Inherited Members
Properties
Code
Gets or sets a number that indicates the error type that occurred.
[DataMember(Name = "code", Order = 0, IsRequired = true)]
[JsonPropertyName("code")]
[JsonPropertyOrder(0)]
[JsonRequired]
[PropertyShape(Name = "code", Order = 0)]
public JsonRpcErrorCode Code { get; set; }
Property Value
- JsonRpcErrorCode
The error codes from and including -32768 to -32000 are reserved for errors defined by the spec or this library. Codes outside that range are available for app-specific error codes.
Data
Gets or sets additional data about the error.
[DataMember(Name = "data", Order = 2, IsRequired = false)]
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
[JsonPropertyName("data")]
[JsonPropertyOrder(2)]
[PropertyShape(Name = "data", Order = 2)]
public object? Data { get; set; }
Property Value
Message
Gets or sets a short description of the error.
[DataMember(Name = "message", Order = 1, IsRequired = true)]
[JsonPropertyName("message")]
[JsonPropertyOrder(1)]
[JsonRequired]
[PropertyShape(Name = "message", Order = 1)]
public string? Message { get; set; }
Property Value
Remarks
The message SHOULD be limited to a concise single sentence.
Methods
GetData(Type)
Gets the value of the Data, taking into account any possible type coercion.
public virtual object? GetData(Type dataType)
Parameters
Returns
- object
The result.
Remarks
Derived types may override this method in order to deserialize the Data
such that it can be assignable to dataType
.
The default implementation does nothing to convert the Data object to match dataType
, but simply returns the existing object.
Derived types should not throw exceptions. This is a best effort method and returning null or some other value is preferable to throwing
as it can disrupt an existing exception handling path.
Exceptions
- ArgumentNullException
Thrown if
dataType
is null.
GetData<T>()
Gets the value of the Data, taking into account any possible type coercion.
public T GetData<T>()
Returns
- T
The result.
Type Parameters
SetExpectedDataType(Type)
Provides a hint for a deferred deserialization of the Data value as to the type argument that will be used when calling GetData<T>() later.
protected virtual void SetExpectedDataType(Type dataType)
Parameters
dataType
TypeThe type that will be used as the generic type argument to GetData<T>().
Remarks
Overriding methods in types that retain buffers used to deserialize should deserialize within this method and clear those buffers to prevent further access to these buffers which may otherwise happen concurrently with a call to DeserializationComplete(JsonRpcMessage) that would recycle the same buffer being deserialized from.