-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from Drednote/fix/scenario
[FIX]: fix scenario event handling and add docs
- Loading branch information
Showing
7 changed files
with
79 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/main/java/io/github/drednote/telegram/exception/type/ScenarioException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package io.github.drednote.telegram.exception.type; | ||
|
||
/** | ||
* Exception that throws during scenario processing. | ||
*/ | ||
public class ScenarioException extends TelegramException { | ||
|
||
public ScenarioException(String message) { | ||
super(message); | ||
} | ||
|
||
public ScenarioException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
|
||
public ScenarioException(Throwable cause) { | ||
super(cause); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/main/java/io/github/drednote/telegram/handler/scenario/ScenarioEventResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package io.github.drednote.telegram.handler.scenario; | ||
|
||
import io.github.drednote.telegram.core.request.UpdateRequest; | ||
import org.springframework.lang.Nullable; | ||
|
||
/** | ||
* Result of a handling event. | ||
* | ||
* @author Ivan Galushko | ||
* @see Scenario#sendEvent(UpdateRequest) | ||
*/ | ||
public interface ScenarioEventResult { | ||
|
||
/** | ||
* @return true if the event was successfully handled, false otherwise. | ||
*/ | ||
boolean success(); | ||
|
||
/** | ||
* @return exception that thrown during scenario processing, null otherwise. | ||
*/ | ||
@Nullable | ||
Exception exception(); | ||
|
||
/** | ||
* Default realization of {@code ScenarioEventResult} | ||
*/ | ||
record SimpleScenarioEventResult( | ||
boolean success, @Nullable Exception exception | ||
) implements ScenarioEventResult {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters