|
|
|
@ -179,8 +179,7 @@ public class CalculatedFieldEntityMessageProcessor extends AbstractContextAwareM |
|
|
|
} catch (Exception e) { |
|
|
|
log.debug("[{}][{}] Failed to initialize CF state", entityId, ctx.getCfId(), e); |
|
|
|
if (e instanceof CalculatedFieldException cfe) { |
|
|
|
persistDebugErrorIfEnabled(cfe, msg.getCallback()); |
|
|
|
return; |
|
|
|
throw cfe; |
|
|
|
} |
|
|
|
throw CalculatedFieldException.builder().ctx(ctx).eventEntity(entityId).cause(e).build(); |
|
|
|
} |
|
|
|
@ -264,8 +263,7 @@ public class CalculatedFieldEntityMessageProcessor extends AbstractContextAwareM |
|
|
|
} catch (Exception e) { |
|
|
|
log.debug("[{}][{}] Failed to handle relation update", entityId, ctx.getCfId(), e); |
|
|
|
if (e instanceof CalculatedFieldException cfe) { |
|
|
|
persistDebugErrorIfEnabled(cfe, msg.getCallback()); |
|
|
|
return; |
|
|
|
throw cfe; |
|
|
|
} |
|
|
|
throw CalculatedFieldException.builder().ctx(ctx).eventEntity(entityId).cause(e).build(); |
|
|
|
} |
|
|
|
@ -304,8 +302,7 @@ public class CalculatedFieldEntityMessageProcessor extends AbstractContextAwareM |
|
|
|
} catch (Exception e) { |
|
|
|
log.debug("[{}][{}] Failed to handle relation delete", entityId, ctx.getCfId(), e); |
|
|
|
if (e instanceof CalculatedFieldException cfe) { |
|
|
|
persistDebugErrorIfEnabled(cfe, msg.getCallback()); |
|
|
|
return; |
|
|
|
throw cfe; |
|
|
|
} |
|
|
|
throw CalculatedFieldException.builder().ctx(ctx).eventEntity(entityId).cause(e).build(); |
|
|
|
} |
|
|
|
@ -351,8 +348,7 @@ public class CalculatedFieldEntityMessageProcessor extends AbstractContextAwareM |
|
|
|
} catch (Exception e) { |
|
|
|
log.debug("[{}][{}] Failed to process linked CF telemetry msg: {}", entityId, ctx.getCfId(), msg, e); |
|
|
|
if (e instanceof CalculatedFieldException cfe) { |
|
|
|
persistDebugErrorIfEnabled(cfe, callback); |
|
|
|
return; |
|
|
|
throw cfe; |
|
|
|
} |
|
|
|
throw CalculatedFieldException.builder().ctx(ctx).eventEntity(entityId).cause(e).build(); |
|
|
|
} |
|
|
|
@ -378,7 +374,10 @@ public class CalculatedFieldEntityMessageProcessor extends AbstractContextAwareM |
|
|
|
} catch (Exception e) { |
|
|
|
log.debug("[{}][{}] Failed to process CF telemetry msg: {}", entityId, ctx.getCfId(), proto, e); |
|
|
|
if (e instanceof CalculatedFieldException cfe) { |
|
|
|
persistDebugErrorIfEnabled(cfe, callback); |
|
|
|
if (DebugModeUtil.isDebugFailuresAvailable(cfe.getCtx().getCalculatedField())) { |
|
|
|
systemContext.persistCalculatedFieldDebugError(cfe); |
|
|
|
} |
|
|
|
callback.onSuccess(); |
|
|
|
return; |
|
|
|
} |
|
|
|
throw CalculatedFieldException.builder().ctx(ctx).eventEntity(entityId).cause(e).build(); |
|
|
|
@ -799,19 +798,4 @@ public class CalculatedFieldEntityMessageProcessor extends AbstractContextAwareM |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
private void persistDebugErrorIfEnabled(CalculatedFieldException cfe, TbCallback callback) { |
|
|
|
if (DebugModeUtil.isDebugFailuresAvailable(cfe.getCtx().getCalculatedField())) { |
|
|
|
String message; |
|
|
|
if (cfe.getErrorMessage() != null) { |
|
|
|
message = cfe.getErrorMessage(); |
|
|
|
} else if (cfe.getCause() != null) { |
|
|
|
message = cfe.getCause().getMessage(); |
|
|
|
} else { |
|
|
|
message = "N/A"; |
|
|
|
} |
|
|
|
systemContext.persistCalculatedFieldDebugEvent(tenantId, cfe.getCtx().getCfId(), cfe.getEventEntity(), cfe.getArguments(), cfe.getMsgId(), cfe.getMsgType(), null, message); |
|
|
|
} |
|
|
|
callback.onSuccess(); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|