-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bot crashes with a TS3CommandFailedException exception #402
Comments
Very little of your information there is particularly helpful. How exactly are you checking if a user is online? Without seeing your code I'm not sure anyone will be able to help you. I recommend the gitter to discuss more, since I stronly suspect you are using the api improperly. |
As I said, the exception actually occurs with every method that the API offers to interact with clients. What else should I write about this? There is not even an explanation why this error is thrown, at least I could not find out anything so far, the links in the readme are partly not accessible anymore. As I said, an example would be this call here: Here I am trying to assign a client to a group. The whole thing works, but at the same time I get the above-mentioned exception. Here is still the whole class, the run method is called every 5 seconds by a scheduler. The whole thing is then in a try-catch. The main class with the try catch EDIT: the configManager returns the an integer and has no errors |
Hi @TOminerTV Exceptions don't propagate out of Timer.scheduleAtFixedRate. I mean, how could they? Your TimerTask runs on a different thread. You need to handle exceptions within your TimerTask's run method. Moreover, consider how things can go wrong, and how you can recover from things going wrong. For example, between the time you ask the server for a list of clients and the time you want to add the client to a group, the client may have disconnected from the server. Or the TS3 server may have crashed / shut down. Or your network connection stopped working. Or you're just plain-old using a command incorrectly. That's what exceptions are for. They give you the opportunity to handle exceptional (ha!) circumstances properly and provide you with information what went wrong (the exception type), why it went wrong (the message), and where it went wrong (the stack trace). Doing stuff like returning null or -1 might seem like a good idea to you, until you actually have to work with code that does that. You'll have zero information about what or why something failed in your code, and if you forget to check everything for null / -1 / whatever, you may get errors in a completely different part of your program. In essence, even with what you have in mind, you still need to write proper error handling code, Exceptions just make it much easier to do the right thing compared to an API that constantly returns error values. Also, it would be helpful in the future if you could provide complete and detailed descriptions of the issues you encounter. For example, you mention
yet none of the TS3Api methods get called from within a try block, and as described above, any exceptions originating in your TimerTask will not be caught by your try-catch around Timer.scheduleAtFixedRate. Further, you state that
yet you've not provided us with a complete stack trace of any of the exceptions you're getting. This makes it very difficult to help you find the actual root cause of the issues you're encountering. I'd recommend you read this Jon Skeet blog entry (or at least the checklist version thereof), and, in general, try to put yourself into the shoes of someone who's responding to your question 😄 Cheers |
Hello GitHub,
first of all, very nice api.
Unfortunately it is really buggy, regularly my bot crashes with a TS3CommandFailedException exception.
Examples are: on client kick, on client move, on client group set, etc.
The code that throws this exception is in a try-catch and this try-catch is in another global try-catch, unfortunately this doesn't work, the bot is still available on the Ts3 server but doesn't respond to anything anymore.
What can I do to avoid this problem, I check every time if the user is online but this does not work.
Is it possible to get null or boolean values from these methods instead of a bot crashing exception?
With kind regards
Tobias
The text was updated successfully, but these errors were encountered: