This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch asf-site
in repository https://gitbox.apache.org/repos/asf/groovy-website.git


The following commit(s) were added to refs/heads/asf-site by this push:
     new 155a9bf  async/await draft post (additional refinements)
155a9bf is described below

commit 155a9bfe42a7a5b7a028971384e5c1a1c0c42366
Author: Paul King <[email protected]>
AuthorDate: Thu Mar 26 13:26:37 2026 +1000

    async/await draft post (additional refinements)
---
 site/src/site/blog/groovy-async-await.adoc | 27 +++++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/site/src/site/blog/groovy-async-await.adoc 
b/site/src/site/blog/groovy-async-await.adoc
index 02c17e9..8433f7d 100644
--- a/site/src/site/blog/groovy-async-await.adoc
+++ b/site/src/site/blog/groovy-async-await.adoc
@@ -111,10 +111,29 @@ async Quest loadHeroQuest(String loginToken) {
 ----
 
 Variables are declared at the point of use. The return value is
-obvious. No callbacks, no lambdas, no chained combinators. Standard
-`try`/`catch` works — and `await` automatically unwraps
-`CompletionException`, so you catch the _original_ exception type,
-not a wrapper.
+obvious. No callbacks, no lambdas, no chained combinators.
+
+What about the `.exceptionally(e -> Quest.DEFAULT)` fallback from
+the Java version? With `async`/`await`, it's just a `try`/`catch`:
+
+[source,groovy]
+----
+async Quest loadHeroQuest(String loginToken) {
+    try {
+        var heroId    = await lookupHeroId(loginToken)
+        var heroClass = await fetchHeroClass(heroId)
+        return await loadActiveQuest(heroClass)
+    } catch (NoActiveQuestException e) {
+        return Quest.DEFAULT
+    }
+}
+----
+
+`await` automatically unwraps `CompletionException`, so you catch
+the _original_ exception type — `NoActiveQuestException` here, not
+a `CompletionException` wrapper. Error handling reads exactly like
+synchronous code — no separate `.exceptionally()` callback bolted
+on at the end of a chain.
 
 == Example 2: preparing for battle — fetch once, await together
 

Reply via email to