Skip to content

Commit f1efac5

Browse files
committed
Update Java example to use type-safe Client.Execute.
1 parent 4eaa167 commit f1efac5

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

‎example/java/org/drinkless/tdlib/example/Example.java‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -302,17 +302,16 @@ public static void main(String[] args) throws InterruptedException {
302302
Client.setLogMessageHandler(0, new LogMessageHandler());
303303

304304
// disable TDLib log and redirect fatal errors and plain log messages to a file
305-
Client.execute(new TdApi.SetLogVerbosityLevel(0));
306-
if (Client.execute(new TdApi.SetLogStream(new TdApi.LogStreamFile("tdlib.log", 1 << 27, false))) instanceof TdApi.Error) {
305+
try {
306+
Client.execute(new TdApi.SetLogVerbosityLevel(0));
307+
Client.execute(new TdApi.SetLogStream(new TdApi.LogStreamFile("tdlib.log", 1 << 27, false)));
308+
} catch (Client.ExecutionException error) {
307309
throw new IOError(new IOException("Write access to the current directory is required"));
308310
}
309311

310312
// create client
311313
client = Client.create(new UpdateHandler(), null, null);
312314

313-
// test Client.execute
314-
defaultHandler.onResult(Client.execute(new TdApi.GetTextEntities("@telegram /test_command https://telegram.org telegram.me @gif @test")));
315-
316315
// main loop
317316
while (!needQuit) {
318317
// await authorization

0 commit comments

Comments
 (0)