# \#error

**URL:** https://forums.swift.org/tag/error/116.md

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

---

## [Handling C++ exceptions in Swift: \`SWIFT\_THROWS\` and \`throws!\`](https://forums.swift.org/t/handling-c-exceptions-in-swift-swift-throws-and-throws/89732)

<div class="topic-metadata">

**Author:** [@mrousavy](https://forums.swift.org/u/mrousavy)\
**Replies:** 7\
**Last updated:** [September 25, 2026, 5:11pm UTC](https://forums.swift.org/t/handling-c-exceptions-in-swift-swift-throws-and-throws/89732 "2026-09-25T17:11:27Z")

</div>

Hi everyone, I'd like to work on handling C++ exceptions from Swift and discuss how the APIs should be imported before getting too far into the implementation. Currently, Swift cannot catch a C++ exception that escapes…

---

## [Help with calc app pls](https://forums.swift.org/t/help-with-calc-app-pls/87668)

<div class="topic-metadata">

**Author:** [@mub](https://forums.swift.org/u/mub)\
**Replies:** 8\
**Last updated:** [June 29, 2026, 6:07am UTC](https://forums.swift.org/t/help-with-calc-app-pls/87668 "2026-06-29T06:07:51Z")

</div>

can someone simpliy my calc app??? :weary\_face::weary\_face::weary\_face: import SwiftUI enum calculatorButton: String { \*\*case\*\* one, two, three, four, five, six, seven, eight, nine, zero, equal, plus, minus, multiply,…

---

## [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…

---

## [The officially recommended way to read from a file](https://forums.swift.org/t/the-officially-recommended-way-to-read-from-a-file/83485)

<div class="topic-metadata">

**Author:** [@jeremyabannister](https://forums.swift.org/u/jeremyabannister)\
**Replies:** 4\
**Last updated:** [December 14, 2025, 10:52pm UTC](https://forums.swift.org/t/the-officially-recommended-way-to-read-from-a-file/83485 "2025-12-14T22:52:02Z")

</div>

The documentation of FileManager.fileExists(at:) includes this note: Note: Attempting to predicate behavior based on the current state of the file system or a particular file on the file system is not recommended. Doi…

---

## [Potential Structural Swift Concurrency Issue: unsafeForcedSync called from Swift Concurrent context](https://forums.swift.org/t/potential-structural-swift-concurrency-issue-unsafeforcedsync-called-from-swift-concurrent-context/82412)

<div class="topic-metadata">

**Author:** [@moreindirection](https://forums.swift.org/u/moreindirection)\
**Replies:** 4\
**Last updated:** [September 29, 2025, 11:01am UTC](https://forums.swift.org/t/potential-structural-swift-concurrency-issue-unsafeforcedsync-called-from-swift-concurrent-context/82412 "2025-09-29T11:01:23Z")

</div>

I occasionally get the below runtime error in Xcode’s console: Potential Structural Swift Concurrency Issue: unsafeForcedSync called from Swift Concurrent context. What does this mean, and how can I resolve it? Googlin…

---

## [SOLVED \[Build Error\] Toolchain executables missing when building \`swiftpm\`, \`swiftsyntax\`, \`sourcekit-lsp\`, \`sourcekit-lsp-lint\`](https://forums.swift.org/t/solved-build-error-toolchain-executables-missing-when-building-swiftpm-swiftsyntax-sourcekit-lsp-sourcekit-lsp-lint/72206)

<div class="topic-metadata">

**Author:** [@00buggy00](https://forums.swift.org/u/00buggy00)\
**Replies:** 3\
**Last updated:** [July 7, 2025, 2:37pm UTC](https://forums.swift.org/t/solved-build-error-toolchain-executables-missing-when-building-swiftpm-swiftsyntax-sourcekit-lsp-sourcekit-lsp-lint/72206 "2025-07-07T14:37:33Z")

</div>

I'm getting an error telling me swift-run is unknown or missing. Here is my process so far: The command I tried after completing Getting Started: utils/build-script --skip-build-benchmarks --skip-ios --skip-watchos \\ …

---

## [Swift-testing and Errors with associated types](https://forums.swift.org/t/swift-testing-and-errors-with-associated-types/79969)

<div class="topic-metadata">

**Author:** [@carlynorama](https://forums.swift.org/u/carlynorama)\
**Replies:** 14\
**Last updated:** [May 22, 2025, 1:10pm UTC](https://forums.swift.org/t/swift-testing-and-errors-with-associated-types/79969 "2025-05-22T13:10:22Z")

</div>

Just wondering if there is a more succinct syntax than what I'm doing below when trying to test Errors when the Error type has associated types? Specifically anything better I could be doing than the switch statements w…

---

## [Confusion surrounding new(?) error output structure — multiple errors associated with the same source location?](https://forums.swift.org/t/confusion-surrounding-new-error-output-structure-multiple-errors-associated-with-the-same-source-location/79527)

<div class="topic-metadata">

**Author:** [@NSExceptional](https://forums.swift.org/u/NSExceptional)\
**Replies:** 8\
**Last updated:** [April 28, 2025, 11:51pm UTC](https://forums.swift.org/t/confusion-surrounding-new-error-output-structure-multiple-errors-associated-with-the-same-source-location/79527 "2025-04-28T23:51:50Z")

</div>

Looks like with Xcode 16, some errors have started coming in like this, where the same file:line:col of some decl will be reused over and over for multiple different errors within that decl, such as a class decl or an ex…

---

## [Preferred Patterns for public error APIs](https://forums.swift.org/t/preferred-patterns-for-public-error-apis/78849)

<div class="topic-metadata">

**Author:** [@ncooke3](https://forums.swift.org/u/ncooke3)\
**Replies:** 0\
**Last updated:** [March 26, 2025, 2:27pm UTC](https://forums.swift.org/t/preferred-patterns-for-public-error-apis/78849 "2025-03-26T14:27:12Z")

</div>

While Swift errors can be defined using enums, the lack of support for non-frozen enums presents challenges (context: non-frozen pitch, extensible pitch. Adding a case to a public error API that uses a non-frozen enum…

---

## [Error the when connecting to server db / making requests](https://forums.swift.org/t/error-the-when-connecting-to-server-db-making-requests/78828)

<div class="topic-metadata">

**Author:** [@Buiscits](https://forums.swift.org/u/Buiscits)\
**Replies:** 5\
**Last updated:** [March 26, 2025, 1:34pm UTC](https://forums.swift.org/t/error-the-when-connecting-to-server-db-making-requests/78828 "2025-03-26T13:34:10Z")

</div>

Hi, I've recently started getting an error when trying to make requests to my server. I suspect this has to do with Fluent (I'm using psql) but honestly not sure what is the root cause. I am getting the same issue with …

---

## [ISO8601DateFormatter fails to parse a valid ISO-8601 date](https://forums.swift.org/t/iso8601dateformatter-fails-to-parse-a-valid-iso-8601-date/22999)

<div class="topic-metadata">

**Author:** [@mohsen](https://forums.swift.org/u/mohsen)\
**Replies:** 28\
**Last updated:** [March 16, 2025, 7:20pm UTC](https://forums.swift.org/t/iso8601dateformatter-fails-to-parse-a-valid-iso-8601-date/22999 "2025-03-16T19:20:55Z")

</div>

Although, 2017-09-04T04:14:37.000Z is a valid ISO8601-formatted date, ISO8601DateFormatter cannot parse it. Seemingly, it happens when the string that represents an ISO8601-formatted date contains fractions of a second: …

---

## [Error creating CFMessagePort…](https://forums.swift.org/t/error-creating-cfmessageport/76908)

<div class="topic-metadata">

**Author:** [@Matthewcramer](https://forums.swift.org/u/Matthewcramer)\
**Replies:** 0\
**Last updated:** [December 29, 2024, 6:47pm UTC](https://forums.swift.org/t/error-creating-cfmessageport/76908 "2024-12-29T18:47:26Z")

</div>

“Error creating the CFMessagePort needed to communicate with PPT” keeps happening to me. I am trying to connect JSON to Swift, but the CFMessagePort isn’t being created. Any advice? Thank you.

---

## [Compile Errors when Using the or-tools C++ Library in an SPM Package](https://forums.swift.org/t/compile-errors-when-using-the-or-tools-c-library-in-an-spm-package/75764)

<div class="topic-metadata">

**Author:** [@SublimeAbode](https://forums.swift.org/u/SublimeAbode)\
**Replies:** 0\
**Last updated:** [November 2, 2024, 2:53am UTC](https://forums.swift.org/t/compile-errors-when-using-the-or-tools-c-library-in-an-spm-package/75764 "2024-11-02T02:53:26Z")

</div>

Hello, I've been trying to use the or-tools C++ library in an SPM package but to no avail. My current strategy involves wrapping the built or-tools dylib into an xcframework, and then adding it as a binary target into my…

---

## [Testing fatalError and friends](https://forums.swift.org/t/testing-fatalerror-and-friends/67317)

<div class="topic-metadata">

**Author:** [@AlexanderM](https://forums.swift.org/u/AlexanderM)\
**Replies:** 74\
**Last updated:** [October 21, 2024, 5:17pm UTC](https://forums.swift.org/t/testing-fatalerror-and-friends/67317 "2024-10-21T17:17:25Z")

</div>

Testing assertions is outstandingly difficult in Swift today. A very informal poll suggests that some other people think so, too. There was a thread on the matter back in 2015, but it didn't get much traction. I would li…

---

## [Compiling the stock "Multiplatform Document App" template results in errors](https://forums.swift.org/t/compiling-the-stock-multiplatform-document-app-template-results-in-errors/75094)

<div class="topic-metadata">

**Author:** [@Refah](https://forums.swift.org/u/Refah)\
**Replies:** 0\
**Last updated:** [October 2, 2024, 12:47am UTC](https://forums.swift.org/t/compiling-the-stock-multiplatform-document-app-template-results-in-errors/75094 "2024-10-02T00:47:02Z")

</div>

Hello! I've noticed that if you compile the stock "Document App" template, Xcode complains about publishing changes from background threads. Doesn't matter if you compile for iOS or for MacOS... Not allowed! Curious to…

---

## [Compiler endless working](https://forums.swift.org/t/compiler-endless-working/74172)

<div class="topic-metadata">

**Author:** [@bastie](https://forums.swift.org/u/bastie)\
**Replies:** 1\
**Last updated:** [August 26, 2024, 4:36pm UTC](https://forums.swift.org/t/compiler-endless-working/74172 "2024-08-26T16:36:36Z")

</div>

Hello, I have a small simple project with target to port a Java lib to Swift. I use both SwiftPM and, with open Package.swift, also Xcode. Some code is ported (in \*.swift files), some not (in \*.java files) and I work a…

---

## [Catch a particular enum case and capture whole error value?](https://forums.swift.org/t/catch-a-particular-enum-case-and-capture-whole-error-value/73485)

<div class="topic-metadata">

**Author:** [@bjhomer](https://forums.swift.org/u/bjhomer)\
**Replies:** 4\
**Last updated:** [July 26, 2024, 5:10pm UTC](https://forums.swift.org/t/catch-a-particular-enum-case-and-capture-whole-error-value/73485 "2024-07-26T17:10:16Z")

</div>

Is it possible to catch a particular error enum case and also preserve the entire error value? Example: enum CookingError: Error { case missingIngredient(Ingredient, quantity: Int) case kitchenOnFire } do { try m…

---

## [Embedded Swift on ESP32 with IDF: error on build](https://forums.swift.org/t/embedded-swift-on-esp32-with-idf-error-on-build/72230)

<div class="topic-metadata">

**Author:** [@scoates](https://forums.swift.org/u/scoates)\
**Replies:** 13\
**Last updated:** [June 24, 2024, 9:13pm UTC](https://forums.swift.org/t/embedded-swift-on-esp32-with-idf-error-on-build/72230 "2024-06-24T21:13:39Z")

</div>

Hello. I recently read Kuba Mracek's article on using Swift in embedded applications, and wanted to give it a try on ESP32. I found esp32-led-strip-sdk, and followed the instructions. I believe I have the toolchain (sw…

---

## [Closure property that throws Typed Error in Swift 6 result in compiling error](https://forums.swift.org/t/closure-property-that-throws-typed-error-in-swift-6-result-in-compiling-error/72433)

<div class="topic-metadata">

**Author:** [@ylorn](https://forums.swift.org/u/ylorn)\
**Replies:** 6\
**Last updated:** [June 13, 2024, 2:40pm UTC](https://forums.swift.org/t/closure-property-that-throws-typed-error-in-swift-6-result-in-compiling-error/72433 "2024-06-13T14:40:23Z")

</div>

I was trying out Swift 6 to play with its new features like the Typed throws introduced with SE-0413, and ran into an unexpected compiling error when using the typed throws closure as instance properties. Here is the cod…

---

## [The synthesized implementation for \`Decodable\` doesn't interact with manual implementations as I would expect](https://forums.swift.org/t/the-synthesized-implementation-for-decodable-doesnt-interact-with-manual-implementations-as-i-would-expect/71028)

<div class="topic-metadata">

**Author:** [@jeremyabannister](https://forums.swift.org/u/jeremyabannister)\
**Replies:** 6\
**Last updated:** [April 2, 2024, 4:53pm UTC](https://forums.swift.org/t/the-synthesized-implementation-for-decodable-doesnt-interact-with-manual-implementations-as-i-would-expect/71028 "2024-04-02T16:53:28Z")

</div>

I was surprised to see that the codingPath contained inside of DecodingError is not populated with the full chain of coding keys when the error is thrown manually. For example, the following code: func test\_nestedDecod…

---

## [Optional\<Error\>'s localizedDescription vs error.debugDescription](https://forums.swift.org/t/optional-error-s-localizeddescription-vs-error-debugdescription/70274)

<div class="topic-metadata">

**Author:** [@tera](https://forums.swift.org/u/tera)\
**Replies:** 1\
**Last updated:** [February 26, 2024, 5:10am UTC](https://forums.swift.org/t/optional-error-s-localizeddescription-vs-error-debugdescription/70274 "2024-02-26T05:10:40Z")

</div>

Quite odd behaviour, isn't it? var error: Error? \_ = error!.localizedDescription // ✅ \_ = error.debugDescription // ✅ \_ = error.localizedDescription // 🛑 Value of optional type '(any Error)?' must be unwrapped t…

---

## [Importing a C function as throwing?](https://forums.swift.org/t/importing-a-c-function-as-throwing/69057)

<div class="topic-metadata">

**Author:** [@aidaan](https://forums.swift.org/u/aidaan)\
**Replies:** 5\
**Last updated:** [December 20, 2023, 10:25pm UTC](https://forums.swift.org/t/importing-a-c-function-as-throwing/69057 "2023-12-20T22:25:11Z")

</div>

I'd like to write a C function (not an objc method) that is imported into swift as a throwing function. I found the swift\_error clang attribute, which looks promising, but I couldn't get it to work. Is this attribute cur…

---

## [Comparing result of \`try?\`](https://forums.swift.org/t/comparing-result-of-try/66937)

<div class="topic-metadata">

**Author:** [@bbrk24](https://forums.swift.org/u/bbrk24)\
**Replies:** 3\
**Last updated:** [August 25, 2023, 3:34am UTC](https://forums.swift.org/t/comparing-result-of-try/66937 "2023-08-25T03:34:32Z")

</div>

I want to check whether the result of a throwing function is a specific value, while suppressing errors: enum E { case foo, bar } func baz() throws -\> E { // ... } if try? baz() == .foo { // ... } However, this…

---

## [Proper way to define and print Errors](https://forums.swift.org/t/proper-way-to-define-and-print-errors/37968)

<div class="topic-metadata">

**Author:** [@mozeryansky](https://forums.swift.org/u/mozeryansky)\
**Replies:** 1\
**Last updated:** [June 8, 2023, 4:47pm UTC](https://forums.swift.org/t/proper-way-to-define-and-print-errors/37968 "2023-06-08T16:47:35Z")

</div>

There seems to be a many ways to define an Error and and many ways to print the error. I've having trouble deciding what's the best way to do this. How has everyone been tackling this? Here are the many ways I know to c…

---

## [Issue Building All of a sudden](https://forums.swift.org/t/issue-building-all-of-a-sudden/65385)

<div class="topic-metadata">

**Author:** [@nonlin](https://forums.swift.org/u/nonlin)\
**Replies:** 12\
**Last updated:** [June 7, 2023, 4:53am UTC](https://forums.swift.org/t/issue-building-all-of-a-sudden/65385 "2023-06-07T04:53:40Z")

</div>

Get Sources/SwiftSyntaxParser/CNodes.swift:13:29 no such module '\_InternalSwiftSyntaxParser' So I was building just fine... I added some code and then I went to build again and now I get the error in title. I commente…

---

## [SwiftUI/EnvironmentObject.swift:70: Fatal error: No ObservableObject of type JunkEventStore found. A View.environmentObject(\_:) for JunkEventStore may be missing as an ancestor of this view](https://forums.swift.org/t/swiftui-environmentobject-swift-fatal-error-no-observableobject-of-type-junkeventstore-found-a-view-environmentobject-for-junkeventstore-may-be-missing-as-an-ancestor-of-this-view/64458)

<div class="topic-metadata">

**Author:** [@johnalex](https://forums.swift.org/u/johnalex)\
**Replies:** 3\
**Last updated:** [April 18, 2023, 12:56pm UTC](https://forums.swift.org/t/swiftui-environmentobject-swift-fatal-error-no-observableobject-of-type-junkeventstore-found-a-view-environmentobject-for-junkeventstore-may-be-missing-as-an-ancestor-of-this-view/64458 "2023-04-18T12:56:44Z")

</div>

Hi Everyone, I don't know if this is the right place for this but I am getting this error and I don't know how to fix it. import SwiftUI struct StartTabView: View { (at)EnvironmentObject var myEvents: EventStore (at)…

---

## [A usage of \`some\` in closure return type that the compiler/Xcode seems to cope with exceptionally poorly](https://forums.swift.org/t/a-usage-of-some-in-closure-return-type-that-the-compiler-xcode-seems-to-cope-with-exceptionally-poorly/64007)

<div class="topic-metadata">

**Author:** [@jeremyabannister](https://forums.swift.org/u/jeremyabannister)\
**Replies:** 2\
**Last updated:** [March 31, 2023, 1:37am UTC](https://forums.swift.org/t/a-usage-of-some-in-closure-return-type-that-the-compiler-xcode-seems-to-cope-with-exceptionally-poorly/64007 "2023-03-31T01:37:17Z")

</div>

I just stumbled upon the very bad reaction that I received from the compiler/Xcode upon writing this function: func foo () { var test: ()-\>some Equatable = { ()-\>Int in 0 } } If I paste this function into a fresh p…

---

## [Problem fixing error message related to optionals](https://forums.swift.org/t/problem-fixing-error-message-related-to-optionals/63789)

<div class="topic-metadata">

**Author:** [@bartvk](https://forums.swift.org/u/bartvk)\
**Replies:** 2\
**Last updated:** [March 19, 2023, 5:49pm UTC](https://forums.swift.org/t/problem-fixing-error-message-related-to-optionals/63789 "2023-03-19T17:49:57Z")

</div>

I've got some code that's generated (by SwiftGraphQL). I'd like to use it, but I'm bumping into an error message. I've tried to minimize the code; the following can be pasted into a playground: public enum Objects { …

---

## [Compiler crash in Swift 5.6](https://forums.swift.org/t/compiler-crash-in-swift-5-6/63434)

<div class="topic-metadata">

**Author:** [@soumyamahunt](https://forums.swift.org/u/soumyamahunt)\
**Replies:** 0\
**Last updated:** [March 1, 2023, 4:55am UTC](https://forums.swift.org/t/compiler-crash-in-swift-5-6/63434 "2023-03-01T04:55:36Z")

</div>

I am getting compiler error in Swift 5.6.3 when trying to build my project after making some changes, please find the branch: GitHub - SwiftyLab/AsyncObjects at cancellation. I am able to build the project in XCode 14.2…

---

## [Allow Error protocol to work with @ rethrows](https://forums.swift.org/t/allow-error-protocol-to-work-with-rethrows/62462)

<div class="topic-metadata">

**Author:** [@soumyamahunt](https://forums.swift.org/u/soumyamahunt)\
**Replies:** 7\
**Last updated:** [January 13, 2023, 2:58pm UTC](https://forums.swift.org/t/allow-error-protocol-to-work-with-rethrows/62462 "2023-01-13T14:58:08Z")

</div>

This proposal expands on the new Rethrowing protocol conformances feature. Currently when building generic types specializing with Error protocol, often we have to add specilaized case for Never type. Making Error rethr…

[Next page](https://forums.swift.org/tag/error/116.md?match_all_tags=true&page=1&tags%5B%5D=error)
