/** * Writes a debug message to the respective loggers. * * @param tag the log tag * @param mess the message to send * @see RobotLog#setGlobalErrorMsg(String) * @see Log#wtf(String, String) */ public static synchronized void wtf(String tag, String mess, Exception ex) { tag = checkNotNull(tag); mess = checkNotNull(mess); ex = checkNotNull(ex); Log.wtf(tag, mess, ex); RobotLog.setGlobalErrorMsg(mess); }
/** * Set a global error message * * <p>Sets the global error message, with the exceptions message appended. Then it rethrows the * given exception. * * @param message error message * @param e a RobotCoreException * @throws RobotCoreException */ public static void setGlobalErrorMsgAndThrow(String message, RobotCoreException e) throws RobotCoreException { setGlobalErrorMsg(message + "\n" + e.getMessage()); throw e; }
public void run() { RobotLog.v("EventLoopRunnable has started"); try { ElapsedTime elapsedEventLoop = new ElapsedTime(); double sMinLoopInterval = 0.001D; long msLoopIntervalStep = 5L; while (!Thread.interrupted()) { while (elapsedEventLoop.time() < sMinLoopInterval) { Thread.sleep(msLoopIntervalStep); } elapsedEventLoop.reset(); if (RobotLog.hasGlobalErrorMsg()) { EventLoopManager.this.buildAndSendTelemetry( "SYSTEM_TELEMETRY", RobotLog.getGlobalErrorMsg()); } if (EventLoopManager.this.elapsedSinceHeartbeatReceived.startTime() == 0.0D) { Thread.sleep(500L); } else if (EventLoopManager.this.elapsedSinceHeartbeatReceived.time() > 2.0D) { EventLoopManager.this.handleDroppedConnection(); EventLoopManager.this.currentPeerAddressAndPort = null; EventLoopManager.this.elapsedSinceHeartbeatReceived = new ElapsedTime(0L); } Iterator syncdDeviceIterator = EventLoopManager.this.syncdDevices.iterator(); SyncdDevice syncdDevice; while (syncdDeviceIterator.hasNext()) { syncdDevice = (SyncdDevice) syncdDeviceIterator.next(); syncdDevice.blockUntilReady(); } boolean unblockOnException = false; try { unblockOnException = true; EventLoopManager.this.eventLoop.loop(); unblockOnException = false; } catch (Exception e) { RobotLog.e("Event loop threw an exception"); RobotLog.logStacktrace(e); String exceptionMessage = e.getClass().getSimpleName() + (e.getMessage() != null ? " - " + e.getMessage() : ""); RobotLog.setGlobalErrorMsg( "User code threw an uncaught exception: " + exceptionMessage); EventLoopManager.this.buildAndSendTelemetry( "SYSTEM_TELEMETRY", RobotLog.getGlobalErrorMsg()); throw new RobotCoreException("EventLoop Exception in loop()"); } finally { if (unblockOnException) { Iterator var9 = EventLoopManager.this.syncdDevices.iterator(); while (var9.hasNext()) { SyncdDevice var10 = (SyncdDevice) var9.next(); var10.startBlockingWork(); } } } syncdDeviceIterator = EventLoopManager.this.syncdDevices.iterator(); while (syncdDeviceIterator.hasNext()) { syncdDevice = (SyncdDevice) syncdDeviceIterator.next(); syncdDevice.startBlockingWork(); } } } catch (InterruptedException var20) { RobotLog.v("EventLoopRunnable interrupted"); EventLoopManager.this.reportRobotStatus(RobotState.STOPPED); } catch (RobotCoreException var21) { RobotLog.v("RobotCoreException in EventLoopManager: " + var21.getMessage()); EventLoopManager.this.reportRobotStatus(RobotState.EMERGENCY_STOP); EventLoopManager.this.buildAndSendTelemetry( "SYSTEM_TELEMETRY", RobotLog.getGlobalErrorMsg()); } try { EventLoopManager.this.eventLoop.teardown(); } catch (Exception var17) { RobotLog.w("Caught exception during looper teardown: " + var17.toString()); RobotLog.logStacktrace(var17); if (RobotLog.hasGlobalErrorMsg()) { EventLoopManager.this.buildAndSendTelemetry( "SYSTEM_TELEMETRY", RobotLog.getGlobalErrorMsg()); } } RobotLog.v("EventLoopRunnable has exited"); }