2021-09-09 18:49:46 +00:00
|
|
|
package me.kavin.piped.utils;
|
|
|
|
|
2022-02-02 21:05:22 +00:00
|
|
|
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
|
|
|
|
|
2021-09-09 18:49:46 +00:00
|
|
|
import java.util.concurrent.CompletionException;
|
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
|
|
|
|
|
public class ExceptionHandler {
|
|
|
|
|
|
|
|
public static Exception handle(Exception e) {
|
2021-11-08 20:35:02 +00:00
|
|
|
return handle(e, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static Exception handle(Exception e, String path) {
|
2021-09-09 18:49:46 +00:00
|
|
|
|
|
|
|
if (e.getCause() != null && (e instanceof ExecutionException || e instanceof CompletionException))
|
|
|
|
e = (Exception) e.getCause();
|
|
|
|
|
2022-02-02 21:05:22 +00:00
|
|
|
if (!(e instanceof ContentNotAvailableException)) {
|
2021-11-08 20:35:02 +00:00
|
|
|
if (path != null)
|
|
|
|
System.err.println("An error occoured in the path: " + path);
|
2021-09-09 18:49:46 +00:00
|
|
|
e.printStackTrace();
|
2021-11-08 20:35:02 +00:00
|
|
|
}
|
2021-09-09 18:49:46 +00:00
|
|
|
|
|
|
|
return e;
|
|
|
|
}
|
|
|
|
}
|