Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8f6b853b6c | ||
|
|
e876486c00 | ||
|
|
e71226be4a |
@@ -71,6 +71,7 @@ public partial class Synapse
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.LogError("Synapse RPC 方法异常: {Err}\n{Stack}", ex.Message,ex.StackTrace);
|
||||
res = new SimApiBaseResponse(500, ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
+25
-1
@@ -13,6 +13,7 @@ using MQTTnet.Formatter;
|
||||
using SimApi.Attributes;
|
||||
using SimApi.Communications;
|
||||
using SimApi.Configurations;
|
||||
using SimApi.Exceptions;
|
||||
using SimApi.Helpers;
|
||||
|
||||
namespace SimApi;
|
||||
@@ -116,8 +117,31 @@ public partial class Synapse(SimApiOptions simApiOptions, ILogger<Synapse> logge
|
||||
return Rpc<object>(appName, method, param);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 只能在Rpc方法中使用,快捷抛出异常返回
|
||||
/// </summary>
|
||||
/// <param name="code"></param>
|
||||
/// <param name="message"></param>
|
||||
/// <exception cref="SimApiException"></exception>
|
||||
public void RpcError(int code, string message = "")
|
||||
{
|
||||
throw new SimApiException(code, message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 如果条件成立,则爆出错误
|
||||
/// </summary>
|
||||
/// <param name="condition"></param>
|
||||
/// <param name="code"></param>
|
||||
/// <param name="message"></param>
|
||||
public void RpcErrorWhen(bool condition, int code, string message = "")
|
||||
{
|
||||
if (condition) RpcError(code, message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送一个事件
|
||||
/// </summary>
|
||||
/// <param name="eventName"></param>
|
||||
/// <param name="param"></param>
|
||||
|
||||
Reference in New Issue
Block a user