# \#do-catch

**URL:** https://forums.swift.org/tag/do-catch/715.md

[Latest](https://forums.swift.org/latest.md) · [Categories](https://forums.swift.org/categories.md) · [Tags](https://forums.swift.org/tags.md)

---

## [Un-nesting the happy path when catching errors](https://forums.swift.org/t/un-nesting-the-happy-path-when-catching-errors/84914)

<div class="topic-metadata">

**Author:** [@jeremyabannister](https://forums.swift.org/u/jeremyabannister)\
**Replies:** 9\
**Last updated:** [February 25, 2026, 10:04pm UTC](https://forums.swift.org/t/un-nesting-the-happy-path-when-catching-errors/84914 "2026-02-25T22:04:07Z")

</div>

The motivation for this idea is that it would be nice if the happy path didn't need to gain a level of indentation just because we want to do some error handling. A solution that occurs to me is the following: readFromD…

---

## [Can nested do-catch blocks explicitly work?](https://forums.swift.org/t/can-nested-do-catch-blocks-explicitly-work/73180)

<div class="topic-metadata">

**Author:** [@CTMacUser](https://forums.swift.org/u/CTMacUser)\
**Replies:** 4\
**Last updated:** [July 16, 2024, 12:48am UTC](https://forums.swift.org/t/can-nested-do-catch-blocks-explicitly-work/73180 "2024-07-16T00:48:58Z")

</div>

// \[0\] do throwable tests, then non-throwable mutation // (The tests are from a predicate that's a parameter for this function.) do { // \[1\] do throwable tests, then non-throwable mutation do { // \[2\] do thro…

---

## [Is there any difference in how exceptions are handled under the hood between 'try?' and 'do/catch'?](https://forums.swift.org/t/is-there-any-difference-in-how-exceptions-are-handled-under-the-hood-between-try-and-do-catch/68104)

<div class="topic-metadata">

**Author:** [@11ag11](https://forums.swift.org/u/11ag11)\
**Replies:** 5\
**Last updated:** [October 29, 2023, 6:13pm UTC](https://forums.swift.org/t/is-there-any-difference-in-how-exceptions-are-handled-under-the-hood-between-try-and-do-catch/68104 "2023-10-29T18:13:58Z")

</div>

I'm reviewing some errors, and I notice that some of them occur in JSONEncoder, where there's a 'try' and I have a 'do/catch' to catch the exception. However, these errors don't reach the 'catch,' causing the app to cra…

---

## [Do-catch behavior in Xcode](https://forums.swift.org/t/do-catch-behavior-in-xcode/58912)

<div class="topic-metadata">

**Author:** [@schornon](https://forums.swift.org/u/schornon)\
**Replies:** 2\
**Last updated:** [July 30, 2022, 9:11pm UTC](https://forums.swift.org/t/do-catch-behavior-in-xcode/58912 "2022-07-30T21:11:40Z")

</div>

While fixing a bug in my project, I catch an interesting behavior of do-catch: enum KnownError: Error { case oops } enum UnknownError: Error { case unknown } func methodThatThrowUnknownError() throws { thro…
