'Java Not Catching A ContextException Error [duplicate]

I was making a function to ban a member using his/her id in JDA.
I made this:

private void banID(@NotNull MessageReceivedEvent event, String @NotNull [] args) {
        System.out.println("e");
        try {
            args[1] = args[1].trim();
            event.getGuild().ban(args[1], 0).queue();
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("Done");
            System.out.println(e.getMessage());
            System.out.println("EEE");
        }
        System.out.println("E");
    }

But, it doesn't accept the error. I've tried removing the printStackTrace, but the error still raises. "Done", and "EEE" are not printed.
Also, it does accept every other error, but not this.
Here is a part of the error given

e
E
[ForkJoinPool.commonPool-worker-1] ERROR RestAction - RestAction queue returned failure: [ErrorResponseException] 10013: Unknown User
net.dv8tion.jda.api.exceptions.ContextException
    at net.dv8tion.jda.api.exceptions.ContextException.here(ContextException.java:54)
    at net.dv8tion.jda.api.requests.Request.<init>(Request.java:71)
    at net.dv8tion.jda.internal.requests.RestActionImpl.queue(RestActionImpl.java:197)
    at net.dv8tion.jda.api.requests.RestAction.queue(RestAction.java:573)
    at net.dv8tion.jda.api.requests.RestAction.queue(RestAction.java:539)
    at com.television.Commands.Ban.banID(Ban.java:56)
    at com.television.Commands.Ban.<init>(Ban.java:31)
    at com.television.CommandExecutor.onMessageReceived(CommandExecutor.java:33)
    at net.dv8tion.jda.api.hooks.ListenerAdapter.onEvent(ListenerAdapter.java:359)
    


Solution 1:[1]

You are using

 System.out.println("E"); 

after your catch block. The output you provided however indicates that the exception is thrown later on.

e
E
[ForkJoinPool.commonPool-worker-1] ERROR RestAction - RestAction queue returned failure: [ErrorResponseException] 10013: 
Unknown User   net.dv8tion.jda.api.exceptions.ContextException at net.dv8tion.jda.api.exceptions.ContextException.here(ContextException.java:54)at net.dv8tion.jda.api.requests.Request.<init>(Request.java:71) 

I guess the error is somewhere else in your Code. It does not seem to be in the part that you have shown.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 GJohannes