private void run()

in src/main/java/org/apache/sling/scripting/sightly/js/impl/loop/EventLoop.java [48:75]


    private void run() {
        if (isRunning) {
            return;
        }
        isRunning = true;
        try {
            // Holds the first exception encountered. If there is such a first exception, it will be
            // rethrown
            Exception thrownException = null;
            while (!taskQueue.isEmpty()) {
                Task task = taskQueue.poll();
                try {
                    task.run();
                } catch (Exception e) {
                    if (thrownException == null) {
                        thrownException = e; // first exception
                    } else {
                        log.error("Additional error occurred while running JS script: ", e);
                    }
                }
            }
            if (thrownException != null) {
                throw new SightlyException(thrownException);
            }
        } finally {
            isRunning = false;
        }
    }