mirror of
https://github.com/github/awesome-copilot.git
synced 2026-04-11 02:35:55 +00:00
Update cookbook/copilot-sdk/java/recipe/ErrorHandling.java
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -11,18 +11,17 @@ public class ErrorHandling {
|
|||||||
try (var client = new CopilotClient()) {
|
try (var client = new CopilotClient()) {
|
||||||
client.start().get();
|
client.start().get();
|
||||||
|
|
||||||
var session = client.createSession(
|
try (var session = client.createSession(
|
||||||
new SessionConfig()
|
new SessionConfig()
|
||||||
.setOnPermissionRequest(PermissionHandler.APPROVE_ALL)
|
.setOnPermissionRequest(PermissionHandler.APPROVE_ALL)
|
||||||
.setModel("gpt-5")).get();
|
.setModel("gpt-5")).get()) {
|
||||||
|
|
||||||
session.on(AssistantMessageEvent.class,
|
session.on(AssistantMessageEvent.class,
|
||||||
msg -> System.out.println(msg.getData().content()));
|
msg -> System.out.println(msg.getData().content()));
|
||||||
|
|
||||||
session.sendAndWait(
|
session.sendAndWait(
|
||||||
new MessageOptions().setPrompt("Hello!")).get();
|
new MessageOptions().setPrompt("Hello!")).get();
|
||||||
|
}
|
||||||
session.close();
|
|
||||||
} catch (ExecutionException ex) {
|
} catch (ExecutionException ex) {
|
||||||
Throwable cause = ex.getCause();
|
Throwable cause = ex.getCause();
|
||||||
Throwable error = cause != null ? cause : ex;
|
Throwable error = cause != null ? cause : ex;
|
||||||
|
|||||||
Reference in New Issue
Block a user