|
|
@ -16,6 +16,7 @@ |
|
|
package org.thingsboard.server.common.data; |
|
|
package org.thingsboard.server.common.data; |
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.databind.JsonNode; |
|
|
import com.fasterxml.jackson.databind.JsonNode; |
|
|
|
|
|
import com.google.common.base.Throwables; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.thingsboard.server.common.data.edge.EdgeEvent; |
|
|
import org.thingsboard.server.common.data.edge.EdgeEvent; |
|
|
import org.thingsboard.server.common.data.edge.EdgeEventActionType; |
|
|
import org.thingsboard.server.common.data.edge.EdgeEventActionType; |
|
|
@ -29,6 +30,8 @@ import java.util.concurrent.ThreadLocalRandom; |
|
|
@Slf4j |
|
|
@Slf4j |
|
|
public final class EdgeUtils { |
|
|
public final class EdgeUtils { |
|
|
|
|
|
|
|
|
|
|
|
private static final int STACK_TRACE_LIMIT = 10; |
|
|
|
|
|
|
|
|
private EdgeUtils() { |
|
|
private EdgeUtils() { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -93,4 +96,20 @@ public final class EdgeUtils { |
|
|
edgeEvent.setBody(body); |
|
|
edgeEvent.setBody(body); |
|
|
return edgeEvent; |
|
|
return edgeEvent; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static String createErrorMsgFromRootCauseAndStackTrace(Throwable t) { |
|
|
|
|
|
Throwable rootCause = Throwables.getRootCause(t); |
|
|
|
|
|
StringBuilder errorMsg = new StringBuilder(rootCause.getMessage() != null ? rootCause.getMessage() : ""); |
|
|
|
|
|
if (rootCause.getStackTrace().length > 0) { |
|
|
|
|
|
int idx = 0; |
|
|
|
|
|
for (StackTraceElement stackTraceElement : rootCause.getStackTrace()) { |
|
|
|
|
|
errorMsg.append("\n").append(stackTraceElement.toString()); |
|
|
|
|
|
idx++; |
|
|
|
|
|
if (idx > STACK_TRACE_LIMIT) { |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return errorMsg.toString(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|