public static void dumpStateToFile()

in harry-core/src/harry/runner/Runner.java [409:454]


    public static void dumpStateToFile(Run run, Configuration config, List<Throwable> t)
    {
        try
        {
            File f = new File("failure.dump");
            logger.error("Dumping results into the file:" + f);
            try (BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f))))
            {
                bw.write("Caught exception during the run: ");
                for (Throwable throwable : t)
                    dumpExceptionToFile(bw, throwable);

                bw.flush();
            }

            File file = new File("run.yaml");
            Configuration.ConfigurationBuilder builder = config.unbuild();

            // override stateful components
            builder.setClock(run.clock.toConfig());
            builder.setDataTracker(run.tracker.toConfig());

            Configuration.toFile(file, builder.build());
        }

        catch (Throwable e)
        {
            logger.error("Caught an error while trying to dump to file", e);
            try
            {
                File f = new File("tmp.dump");
                
                if (!f.createNewFile())
                    logger.info("File {} already exists. Appending...", f);
                
                BufferedWriter tmp = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f)));
                dumpExceptionToFile(tmp, e);
            }
            catch (IOException ex)
            {
                ex.printStackTrace();
            }

            throw new RuntimeException(e);
        }
    }