Java Code Examples for com.sedmelluq.discord.lavaplayer.tools.ExceptionTools#log()

The following examples show how to use com.sedmelluq.discord.lavaplayer.tools.ExceptionTools#log() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UserContextAudioPlayerManager.java    From SkyBot with GNU Affero General Public License v3.0 5 votes vote down vote up
private Future<Void> handleLoadRejected(String identifier, AudioLoadResultHandler resultHandler, RejectedExecutionException e) {
    final FriendlyException exception = new FriendlyException("Cannot queue loading a track, queue is full.", SUSPICIOUS, e);
    ExceptionTools.log(log, exception, "queueing item " + identifier);

    resultHandler.loadFailed(exception);

    return ExecutorTools.COMPLETED_VOID;
}
 
Example 2
Source File: UserContextAudioPlayerManager.java    From SkyBot with GNU Affero General Public License v3.0 5 votes vote down vote up
private void dispatchItemLoadFailure(String identifier, AudioLoadResultHandler resultHandler, Throwable throwable) {
    final FriendlyException exception = ExceptionTools.wrapUnfriendlyExceptions("Something went wrong when looking up the track", FAULT, throwable);

    if (!(throwable instanceof LimitReachedException)) {
        ExceptionTools.log(log, exception, "loading item " + identifier);
    }

    resultHandler.loadFailed(exception);
}
 
Example 3
Source File: DefaultAudioPlayerManager.java    From lavaplayer with Apache License 2.0 5 votes vote down vote up
private Future<Void> handleLoadRejected(String identifier, AudioLoadResultHandler resultHandler, RejectedExecutionException e) {
  FriendlyException exception = new FriendlyException("Cannot queue loading a track, queue is full.", SUSPICIOUS, e);
  ExceptionTools.log(log, exception, "queueing item " + identifier);

  resultHandler.loadFailed(exception);

  return ExecutorTools.COMPLETED_VOID;
}
 
Example 4
Source File: RemoteAudioTrackExecutor.java    From lavaplayer with Apache License 2.0 5 votes vote down vote up
/**
 * Send the specified exception as an event to the active state listener.
 * @param exception Exception to send
 */
public void dispatchException(FriendlyException exception) {
  TrackStateListener currentListener = activeListener;

  ExceptionTools.log(log, exception, track.getIdentifier());

  if (currentListener != null) {
    trackException = exception;
    currentListener.onTrackException(track, exception);
  }
}
 
Example 5
Source File: DefaultAudioPlayerManager.java    From lavaplayer with Apache License 2.0 4 votes vote down vote up
private void dispatchItemLoadFailure(String identifier, AudioLoadResultHandler resultHandler, Throwable throwable) {
  FriendlyException exception = ExceptionTools.wrapUnfriendlyExceptions("Something went wrong when looking up the track", FAULT, throwable);
  ExceptionTools.log(log, exception, "loading item " + identifier);

  resultHandler.loadFailed(exception);
}
 
Example 6
Source File: LocalAudioTrackExecutor.java    From lavaplayer with Apache License 2.0 4 votes vote down vote up
@Override
public void execute(TrackStateListener listener) {
  InterruptedException interrupt = null;

  if (Thread.interrupted()) {
    log.debug("Cleared a stray interrupt.");
  }

  if (playingThread.compareAndSet(null, Thread.currentThread())) {
    log.debug("Starting to play track {} locally with listener {}", audioTrack.getInfo().identifier, listener);

    state.set(AudioTrackState.LOADING);

    try {
      audioTrack.process(this);

      log.debug("Playing track {} finished or was stopped.", audioTrack.getIdentifier());
    } catch (Throwable e) {
      // Temporarily clear the interrupted status so it would not disrupt listener methods.
      interrupt = findInterrupt(e);

      if (interrupt != null && checkStopped()) {
        log.debug("Track {} was interrupted outside of execution loop.", audioTrack.getIdentifier());
      } else {
        frameBuffer.setTerminateOnEmpty();

        FriendlyException exception = ExceptionTools.wrapUnfriendlyExceptions("Something broke when playing the track.", FAULT, e);
        ExceptionTools.log(log, exception, "playback of " + audioTrack.getIdentifier());

        trackException = exception;
        listener.onTrackException(audioTrack, exception);

        ExceptionTools.rethrowErrors(e);
      }
    } finally {
      synchronized (actionSynchronizer) {
        interrupt = interrupt != null ? interrupt : findInterrupt(null);

        playingThread.compareAndSet(Thread.currentThread(), null);

        markerTracker.trigger(ENDED);
        state.set(AudioTrackState.FINISHED);
      }

      if (interrupt != null) {
        Thread.currentThread().interrupt();
      }
    }
  } else {
    log.warn("Tried to start an already playing track {}", audioTrack.getIdentifier());
  }
}