Solved Checking Console?

Discussion in 'Spigot Plugin Development' started by Leniency, May 29, 2016.

Thread Status:
Not open for further replies.
  1. How would I detect when any error is shown in the console? I'm pretty sure there is a way to do this (probably with normal java methods and not using the spigot API), but I just can't find it. Can someone help me with this?
  2. Code (Text):
    try {
    //code that may have an error
    } catch (Exception e) {
    //What to say or do when there is an error
  3. That's not what I need. I'm trying to catch when an error is thrown by any plugin, any code or anything else.
  4. Well you'd have to build a try-catch around everything then. So basically around the main method of Spigot itself. Doing it plugin-side could be difficult. But it may be possible with some reflection magic.
  5. That's what I'm wondering how to do. Right now my best bet is to get access to the spigot source code from stash and modify the logger methods to catch errors and exceptions Nd do what I want .
  6. Bump - Looking for an easier alternative to this:
    But if this is the only way, could someone point me to where i should start.
  7. look for available errors in config such as NullPointerException , and more.
    • Funny Funny x 1
    • Optimistic Optimistic x 1
  8. Which console? You mean the log file?
    I was thinking of doing this by loading the latest log file and checking, but I'm not sure if that file updates instantly along with console .
    Good idea though :)
  9. @Vexentric implement Appender (or extend AppenderSkeleton for basic functionality), and make getErrorHandler() return a custom ErrorHandler which tracks the errors
    • Agree Agree x 1
  10. Put System.out.println("Possible error)
    • Funny Funny x 3
    • Like Like x 1
    • Optimistic Optimistic x 1
  11. Oh thanks so much. I'll try this out and see if it works.
    You obviously have no idea what we are trying to do here. You cant even type a single line properly.
  12. Meaby editting the log or geting the log some world like [ERROR]
  13. somewhere says [ERROR]null

    stack trace.
  14. There is a pretty easy way to do this, I just forgot hoe I did it and will reply when I'm at home.
  15. That's what I'm thinking, but as I said:
    Nice copy m8
    Please tell me :eek:
  16. what do you mean by copy ? are you going to complain to what you've seen or you should put what we've said in your mind do you really want to learn how ? still interested ?.
  17. @Vexentric about my suggestion, I tested it out. And what you need to do is extend AbstractAppender and override the abstract method which I forgot the name of which has a LogEvent argument. Check if LogEvent#getThrown() is not null and if it isn't, you have yourself an error.
Thread Status:
Not open for further replies.