Solved Override reloadConfig() with custom error.

Discussion in 'Plugin Development' started by DirtyRedz, Apr 23, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    DirtyRedz

    Ok so say you call
    this.reloadConfig()

    but someone has messed the file up and your gonna get an error in your console.
    The error is going to come from the class:

    YamlConfiguration

    method:
    Code:java
    1. public static YamlConfiguration loadConfiguration(File file) {
    2. Validate.notNull(file, "File cannot be null");
    3.  
    4. YamlConfiguration config = new YamlConfiguration();
    5.  
    6. try {
    7. config.load(file);
    8. } catch (FileNotFoundException ex) {
    9. } catch (IOException ex) {
    10. Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, ex);
    11. } catch (InvalidConfigurationException ex) {
    12. Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file , ex);
    13. }
    14.  
    15. return config;
    16. }


    So my question here is it possible to stop this method from writing to the config and writing your on error, or specifically writing the stacktrace to a separate log.
     
  2. Offline

    ButterSquidz

    The method will not write to the config since it stops the execution of the thread whenever an exception is throws. For writing to separate files you can use
    Code:java
    1. ex.printStackTrace(PrintStream stream);
     
  3. Offline

    DirtyRedz

    Sry I thought I explained it better, my code won't throw an exception because the yaml class method is throwing the exception and is being caught abed printed before it comes back to my method. The only thing I've seen is to rewrite the yaml class method and put my custom try catch Thier
     
Thread Status:
Not open for further replies.

Share This Page