Get error message

Discussion in 'Spigot Plugin Development' started by 56awesome56, Jun 25, 2015.

  1. Since I don't have console on the server I dev for, I can't always check the console for errors, so I thought it would be helpful to upload errors to pastebin, and message link. I'm not exactly sure how to go about actually getting the error when it happens, as for uploading to pastebin, I'll figure that out on my own. I could use
    Code (Text):
    and make a custom error handler, but I'm not sure how to tell when an error has finished printing. Is there a better way to do this, or is there an easy way to check?
  2. Can't you just use ingame broadcast / player messages?

    Do you have access to the servers file system, like, can you access the server log files?
    If yes, you can see everything that happens in the console in the log file as well.

    If you really want to use Pastebin for that you should look if they have an API or something you could use for that.
    If they do have an API, you would need to create a console-to-pastebin application that catches all console outputs and puts them into some sort of storage and posts it to pastebin once you make a request.

  4. Well that answers my question if there is an API :D
    Refer to my "solution" then, if you really want to use pastebin.
  5. I mean, I could upload logs to pastebin every certain number of minutes, but it would be nice to be notified when there's an error, and it would be much more efficient to just upload the error, and only upload it when I need to.
    #5 56awesome56, Jun 25, 2015
    Last edited: Jun 26, 2015
  6. That should be achievable, but would require a given amount of webcomputing skills.
    If you want to be notified on an error you COULD (I will explicitly NOT recommend this) put a BIG try-catch statement "around your whole" plugin and use that for notifications about serious (Exceptions) errors. If you have split your plugin into many different classes, that would require an corresponding amount of try-catchs (e.g. for every event, command, etc.)

    Another solution would be to implement some sort of "error-notification-interface" in your code, that would recognise when and where an error happens.
  7. Solved, I used a regex to test if it was an error, after using System.setOut. It only gets the first part of the stack trace, but it's sufficient