Stack errors = new Stack(); mw.setErrorStack(errors);
PluginLogger logger = new PluginLogger(); mw.setLogger(logger);
    public static void saveMap(Map currentMap, String filename)        throws Exception    {        MapWriter mw;        if (filename.endsWith("tmx") || filename.endsWith("tmx.gz")) {            // Override, so people can't overtake our format            mw = new XMLMapWriter();        } else {            mw = (MapWriter)pluginLoader.getWriterFor(filename);        }        if (mw != null) {            Stack errors = new Stack();            mw.setErrorStack(errors);            mw.writeMap(currentMap, filename);            currentMap.setFilename(filename);            reportPluginMessages(errors);        } else {            throw new Exception("Unsupported map format");        }    }