123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- 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();
- }
- }
- }
- }
|