using JsonRPC4.Common; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; namespace JsonRPC4.Router { public class RpcResponse { public RpcId Id { get; private set; } public object Result { get; private set; } public RpcError Error { get; private set; } public bool HasError => Error != null; protected RpcResponse() { } protected RpcResponse(RpcId id) { Id = id; } public RpcResponse(RpcId id, RpcError error) : this(id) { Error = error; } public RpcResponse(RpcId id, object result) : this(id) { Result = result; } public void ThrowErrorIfExists() { if (HasError) { throw Error.CreateException(); } } } }