namespace Serein.Proto.HttpApi
{
///
/// 调用结果
///
public class InvokeResult
{
///
/// 处理工具记录的请求Id,用于匹配请求与响应
///
public long RequestId { get; set; }
///
/// 调用状态
///
public HandleState State { get; set; }
///
/// 调用正常时这里会有数据
///
public object? Data{ get; set; }
///
/// 调用失败时这里可能会有异常数据
///
public Exception? Exception { get; set; }
///
/// 调用成功
///
///
///
///
public static InvokeResult Ok(long requestId, object? data) => new InvokeResult
{
RequestId = requestId,
Data = data,
State = HandleState.Ok,
};
///
/// 调用失败
///
///
///
///
///
public static InvokeResult Fail(long requestId, HandleState state, Exception? ex = null) => new InvokeResult
{
RequestId = requestId,
State = state,
Exception = ex,
};
}
}