Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FailableIterator next() crash #1028

Closed
enamor opened this issue Oct 20, 2020 · 5 comments
Closed

FailableIterator next() crash #1028

enamor opened this issue Oct 20, 2020 · 5 comments

Comments

@enamor
Copy link

enamor commented Oct 20, 2020

extension FailableIterator {
public func next() -> Element? {
return try! failableNext()
}
}

Thread 1: Fatal error: 'try!' expression unexpectedly raised an error: disk I/O error (code: 10)

@juanjoseluisgarcia
Copy link

This occurs when more than one thread is trying to access the DB. This library is not thread-friendly. My suggestion is that you create one global connection (in the AppDelegate for example) and use that connection all over your app.

@avnerbarr
Copy link

issue also occurs if the db is open in 2 processes

@nathanfallet
Copy link
Collaborator

Merged a fix to replace try! by try?.

@vitock
Copy link

vitock commented Apr 24, 2023

Merged a fix to replace try! by try?.

I saw you reverted that change ?

@nathanfallet
Copy link
Collaborator

nathanfallet commented Apr 24, 2023

Merged a fix to replace try! by try?.

I saw you reverted that change ?

Yes, because as explained in #1075, you should use failableNext() and handle the error by yourself using a do/catch block. We cannot provide a default behavior (e.g. return nil) when an error occurs, it's up to you to choose what you want to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants