Skip to content

Commit

Permalink
Merge pull request #196 from bivashy/fix/195-vk-messengerexceptionhan…
Browse files Browse the repository at this point in the history
…dler-shouldnt-reply-to-commandactor-if-error-occurs

[Fix] Ignore ApiMessagesDenySendException in VK link
  • Loading branch information
bivashy authored Jul 18, 2024
2 parents fad87f6 + cbbae05 commit 4138c7c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import me.mastercapexd.auth.messenger.commands.MessengerCommandRegistry;
import me.mastercapexd.auth.shared.commands.MessengerLinkCommandTemplate;
import me.mastercapexd.auth.shared.commands.VKLinkCommand;
import me.mastercapexd.auth.vk.command.exception.VKExceptionHandler;
import revxrsal.commands.CommandHandler;

public class VKCommandRegistry extends MessengerCommandRegistry {
Expand All @@ -21,6 +22,7 @@ public class VKCommandRegistry extends MessengerCommandRegistry {
public VKCommandRegistry() {
super(COMMAND_HANDLER, VKLinkType.getInstance());
COMMAND_HANDLER.registerContextResolver(LinkCommandActorWrapper.class, context -> new VKCommandActorWrapper(context.actor()));
COMMAND_HANDLER.setExceptionHandler(new VKExceptionHandler(VKLinkType.getInstance()));
registerCommands();

try {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package me.mastercapexd.auth.vk.command.exception;

import com.bivashy.auth.api.link.LinkType;
import com.vk.api.sdk.exceptions.ApiMessagesDenySendException;
import me.mastercapexd.auth.messenger.commands.exception.MessengerExceptionHandler;
import revxrsal.commands.command.CommandActor;

public class VKExceptionHandler extends MessengerExceptionHandler {

public VKExceptionHandler(LinkType linkType) {
super(linkType);
}

@Override
public void onUnhandledException(CommandActor actor, Throwable throwable) {
if (throwable instanceof ApiMessagesDenySendException)
return;
super.onUnhandledException(actor, throwable);
}

}

0 comments on commit 4138c7c

Please sign in to comment.