Solved Stopping exception from printing to console > YamlConfig.loadConfig

Discussion in 'Plugin Development' started by Lightspeed, Dec 12, 2015.

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

    Lightspeed

    Code:
    FileConfiguration uuidConfig = null;
    try
    {
      uuidConfig =
                YamlConfiguration.loadConfiguration(configFile);
    }
    catch (Exception e)
    {
      System.out.println("WOOPS!");
    }
    I tried this but, it still prints error . . . The code continues perfectly but, it prints an ugly error that I can do nothing about.
     
  2. Offline

    Zombie_Striker

    @Lightspeed
    Can we see the error? The error is there for a reason. Also, please use e.printStackTrace(); Its not about trying to hide the error, it about fixing whats causing it.
     
  3. Offline

    Lightspeed

    @Zombie_Striker The error isn't a problem it's saying omg you have a key without : after it fixing it now and then it's all good code continues. I want it to not tell me this error.
     
  4. Offline

    mythbusterma

    @Lightspeed

    Try not causing the error in the first place.
     
    Zombie_Striker and timtower like this.
  5. Offline

    mcdorli

    Hmm, then maybe put a ":" there?
     
  6. Offline

    Zombie_Striker

    This most likely is your problem. YamlConfugration is most likely not broken. The statement loadConfiguration() is most likely not broken. Most likely, the configFile is causing the problem.

    Can we see what configFile is?
     
  7. Offline

    Lightspeed

    Code:
    Names: Lightspeed360
    Ips: 0
    Currency: 0
    Random: 0
    Warnings: 0
    error
    error
    error
    It will load the file print an error then fix the file continuing my error fixing code with all the "error."
    The system is ment to handle every error keeping it up to date but, this causes an error then fixes.
    What I need is to catch this error and stop it from printing to console if possible.
     
  8. Offline

    mythbusterma

    @Lightspeed

    But why does it need to fix them? There's no reason to introduce errors.
     
  9. Offline

    Lightspeed

    It's a players stats one messup there goes lets say a 100$ rank all thete money this system is ment to fix and recover.
    When it fixes the key without a value it prints an annoying message that can make debugging alot harder to figure out wich error is comin from where.
     
  10. Offline

    mythbusterma

    @Lightspeed

    But why does it create the erroneous config in the first place. There should be no reason why it does that.
     
  11. Offline

    Lightspeed

    @mythbusterma It's ment to fix human error I like everything to fix it's self handle it's self.
     
  12. Offline

    mythbusterma

    @Lightspeed

    So you're trying to fix someone mistyping in your config file?

    Where is the error being thrown and what is it?
     
  13. Offline

    Lightspeed

    @mythbusterma It's when I try YamlConfiguration#loadConfiguration(File file) it somewere not that method somewere in yaml throws a exception I tried extending it and overriding but I can't find were it throws the error inside.
     
    Last edited: Dec 13, 2015
  14. Offline

    mythbusterma

    @Lightspeed

    Just catch the exception when you call loadConfiguration(), and only catch the one you're sure you can fix. Don't just catch Exception.
     
  15. Offline

    Lightspeed

  16. Offline

    mythbusterma

    @Lightspeed

    Well then you've done something wrong.
     
  17. Offline

    Lightspeed

  18. Offline

    mythbusterma

    @Lightspeed

    No, it's not a declared exception.

    [​IMG]

    As you can see, it will catch the Exception. You have to load it a different way.
     
  19. Offline

    Lightspeed

    Thats not the exception I get in the error
    Figured out the annoying problem just created my own system.
    Code:
    YamlConfiguration attemptLoad(File file)
    {
        YamlConfiguration config = new YamlConfiguration();
        try
        {
            config.load(file);
        }
        catch(IOException
            | InvalidConfigurationException e)
        {
            System.out.println("OOPS!");
        }
        return config;
    }
    When you just gotta reverse engineer bukkit.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Dec 13, 2015
  20. Offline

    mythbusterma

    @Lightspeed

    That isn't reverse engineering and that's exactly what I told you to do...
     
  21. Offline

    Lightspeed

    I had to go thru the source code to redo the method . . . I don't see you telling me to do that anywhere.
     
  22. Offline

    mythbusterma

    @Lightspeed

    That's pretty much what the docs say. Try reading the docs next time.
     
    Mrs. bwfctower likes this.
Thread Status:
Not open for further replies.

Share This Page