<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/typed-throws-in-swift-6-3ppjrl9qr" -->

---
title: Typed throws in Swift 6 | daily.dev
description: Swift 6 introduces typed throws via SE-0413, letting a function declare exactly which error type it throws using throws(SomeError) syntax. This gives catch...
canonical: https://daily.dev/posts/typed-throws-in-swift-6-3ppjrl9qr
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Typed throws in Swift 6 | daily.dev
og:description: Swift 6 introduces typed throws via SE-0413, letting a function declare exactly which error type it throws using throws(SomeError) syntax. This gives catch...
og:url: https://daily.dev/posts/typed-throws-in-swift-6-3ppjrl9qr
og:image: https://api.daily.dev/og/posts/3PPjRl9Qr.png
og:image:alt: Typed throws in Swift 6
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Typed throws in Swift 6

**[Sarunw](https://daily.dev/sources/sarunw)** · [@sarunw](https://daily.dev/sarunw) · 6 min read · 0 upvotes · 0 comments

## Summary

Swift 6 introduces typed throws via SE-0413, letting a function declare exactly which error type it throws using throws(SomeError) syntax. This gives catch blocks the concrete error type, enabling compiler-checked exhaustive switch handling instead of casting from any Error. throws(Never) is equivalent to non-throwing, and a generic thrown type parameter can replace rethrows for pass-through cases like map, though only when the closure's error type is explicitly annotated (trailing closures still infer to any Error). The piece argues typed throws is best reserved for single-module code, generic rethrow-style functions, and embedded/dependency-free code where any Error boxing has runtime cost — because pinning a concrete error type on a public API is a source-breaking commitment if the error set ever needs to grow.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://sarunw.com/posts/typed-throws-in-swift>

## Questions this post answers

### How does typed throws work in Swift 6?

Swift 6 lets a function declare exactly what error type it throws using throws(SomeError) syntax, introduced via SE-0413. Inside a matching catch or do block, the implicit error variable takes on that concrete type instead of any Error, so an exhaustive switch over the error's cases is checked by the compiler. throws(Never) means the function never throws, equivalent to no throws keyword at all.

_Developers adopting Swift 6 error handling patterns can track syntax changes like this on daily.dev._

### Does Swift 6 typed throws replace the rethrows keyword?

Yes, for generic pass-through functions like map, a generic thrown type parameter can replace rethrows because it tracks both whether a closure throws and which type it throws, something rethrows never expressed. However, the thrown type is only preserved when it is written down explicitly; a trailing closure passed to map still infers to plain throws, meaning any Error, since inferring a closure's exact thrown type was left as an unshipped future direction in the proposal.

_Teams weighing rethrows against typed throws can follow Swift language evolution details via daily.dev._

### Should I use typed throws on public Swift APIs?

Generally no, untyped throws remains the better default for public API boundaries because pinning a concrete error type is a source-breaking commitment if the error set needs to grow later, such as adding a new error case when a file-loading function gains network support. Typed throws pays off inside a single module, in generic rethrow-style functions, and in embedded or dependency-free code where any Error boxing has a real runtime cost.

_Developers deciding where to apply typed throws can weigh these tradeoffs using guidance surfaced on daily.dev._

## Similar posts on daily.dev

- [TIL: Typed do in Swift](https://daily.dev/posts/til-typed-do-in-swift-hwozicqd3) · Planet Python · 0 upvotes · 0 comments
- [Embedded Swift Improvements Coming in Swift 6.4](https://daily.dev/posts/embedded-swift-improvements-coming-in-swift-6-4-p4nvenuuu) · Swift.org · 1 upvotes · 0 comments
- [Roadmap for improving the type checker](https://daily.dev/posts/roadmap-for-improving-the-type-checker-civoupr6c) · Lobsters · 1 upvotes · 0 comments

---

Tags: [#swift](https://daily.dev/tags/swift), [#type-systems](https://daily.dev/tags/type-systems)

[View this post on daily.dev](https://daily.dev/posts/typed-throws-in-swift-6-3ppjrl9qr)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Typed throws in Swift 6","url":"https://daily.dev/posts/typed-throws-in-swift-6-3ppjrl9qr","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/typed-throws-in-swift-6-3ppjrl9qr"},"datePublished":"2026-09-02T20:01:13.426Z","dateModified":"2026-09-03T17:00:20.570Z","description":"Swift 6 introduces typed throws via SE-0413, letting a function declare exactly which error type it throws using throws(SomeError) syntax. This gives catch...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/4812e2ef075f43b64cf0cdc6140c3da5?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/4812e2ef075f43b64cf0cdc6140c3da5?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Sarunw","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Person","name":"Sarun Wongpatcharapakorn","url":"https://daily.dev/sarunw","image":"https://avatars.githubusercontent.com/u/795368?v=4","interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":20}},"commentCount":0,"discussionUrl":"https://daily.dev/posts/typed-throws-in-swift-6-3ppjrl9qr","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"swift,type-systems","timeRequired":"PT6M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Sarunw","item":"https://daily.dev/sources/sarunw"},{"@type":"ListItem","position":3,"name":"Typed throws in Swift 6"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/typed-throws-in-swift-6-3ppjrl9qr#faq","mainEntity":[{"@type":"Question","name":"How does typed throws work in Swift 6?","acceptedAnswer":{"@type":"Answer","text":"Swift 6 lets a function declare exactly what error type it throws using throws(SomeError) syntax, introduced via SE-0413. Inside a matching catch or do block, the implicit error variable takes on that concrete type instead of any Error, so an exhaustive switch over the error's cases is checked by the compiler. throws(Never) means the function never throws, equivalent to no throws keyword at all. Developers adopting Swift 6 error handling patterns can track syntax changes like this on daily.dev."}},{"@type":"Question","name":"Does Swift 6 typed throws replace the rethrows keyword?","acceptedAnswer":{"@type":"Answer","text":"Yes, for generic pass-through functions like map, a generic thrown type parameter can replace rethrows because it tracks both whether a closure throws and which type it throws, something rethrows never expressed. However, the thrown type is only preserved when it is written down explicitly; a trailing closure passed to map still infers to plain throws, meaning any Error, since inferring a closure's exact thrown type was left as an unshipped future direction in the proposal. Teams weighing rethrows against typed throws can follow Swift language evolution details via daily.dev."}},{"@type":"Question","name":"Should I use typed throws on public Swift APIs?","acceptedAnswer":{"@type":"Answer","text":"Generally no, untyped throws remains the better default for public API boundaries because pinning a concrete error type is a source-breaking commitment if the error set needs to grow later, such as adding a new error case when a file-loading function gains network support. Typed throws pays off inside a single module, in generic rethrow-style functions, and in embedded or dependency-free code where any Error boxing has a real runtime cost. Developers deciding where to apply typed throws can weigh these tradeoffs using guidance surfaced on daily.dev."}}]}
```

