Realm Runtime Error - try-catch

I recently upgraded to Swift 2.0 and now I have been experiencing problems with realm. Most recently, I am experiencing an issue where the app instantly crashes when it reaches the first occurrence of a "try! Realm()" resulting in this error:
fatal error: 'try!' expression unexpectedly raised an error: Error
Domain=io.realm Code=2 "open() failed: No such file or directory"
UserInfo={NSFilePath=/Users/XXXXX/Library/Developer/CoreSimulator/Devices/7299DF18-E7D5-4499-93DD-A5035FB48E67/data/Containers/Data/Application/BED64819-5895-407F-9E90-9888741E24EB/Documents/default.realm,
NSLocalizedDescription=open() failed: No such file or directory, Error
Code=2}: file
/Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-700.0.59/src/swift/stdlib/public/core/ErrorType.swift,
line 50 (lldb)
I saw one other post somewhat related to this, but it did not help because I am not trying to call the path directly, it is just throwing this error.
Thank you

When you use try! in Swift, you're choosing to ignore errors that you could otherwise recover from.
In this case, the Realm initializer is marked as throws. Here's an excerpt from Realm's docs on Error Handling:
Like any disk IO operation, creating a Realm instance could sometimes fail if resources are constrained. In practice, this can only happen the first time a Realm instance is created on a given thread. Subsequent accesses to a Realm from the same thread will reuse a cached instance and will always succeed.
To handle errors when first accessing a Realm on a given thread, use Swift’s built-in error handling mechanism:
do {
let realm = try Realm()
} catch let error as NSError {
// handle error
}

Same thing happened to me when I manually deleted an object from Realm via Realm browser.
Here are my two cents: Deleting realm.lock and other log files and relaunching an app worked for me. Take a look at the screenshot:

Related

EBUSY: resource busy or locked, open

So im making a discord bot and this error showed up:
Unhandled rejection: Error: EBUSY: resource busy or locked, open 'C:\Users\theno\OneDrive\Dokumente\Discord\Bots\FNFA\FNFA\BotFiles\BotData\variables\servervars.json' at Object.openSync (node:fs:582:3) at Object.writeFileSync (node:fs:2143:35) at Object.module.exports.Message_Handle (C:\Users\theno\OneDrive\Dokumente\Discord\Bots\FNFA\FNFA\BotFiles\Handlers\Message.js:33:8) at processTicksAndRejections (node:internal/process/task_queues:96:5)
Anyone knows how to fix this?
The error is what it says: the file is busy or locked. This is likely due to you placing the bot folder inside of your OneDrive, which is known to cause these problems sometimes. Try moving the folder out of your OneDrive and trying again.
As a side note, you probably shouldn't use JSON if you're going to modify it frequently. Constantly parsing and dumping JSON from/into a file will cause more resource usage, won't scale well, and will cause issues if you make requests in quick succession. Instead, you should consider using a database system (e.g. MongoDB, MySQL, etc.)

Topaz Workbench error message: 92003: An error occurred while writing data to the channel

While Topaz Workbench is starting the error message "92003: An error occurred while writing data to the channel" shows up. That is making one of my configured repository to not be listed there. How to resolve it?
Message:
What resolved my case, as a workaround, was to verify the amount of fa_commgr.exe processes in the Task Manager (I am using Windows 10), kill all of them, and then start Topaz again, this way it started normally (without that error message), and my repository was listed again.
Task Manager and fa_commgr.exe process instance (there were 4 instances I don't know why... yet):
My repository was listed again:

ABI issue in standard pancakeswap fork

I am trying to create a fork of pancakeswap/goosedefi. The project works when I check it out from github and start using yarn start.
As soon as I change the contract addresses, symbol, and ABI to match my new project, I get the following error:
"Uncaught (in promise) Error: Returned values aren't valid, did it run Out of Gas? You might also see this error if you are not using the correct ABI for the contract you are retrieving data from, requesting data from a block number that does not exist, or querying a node which is not fully synced"
The ABI matches the ABI generated by BscScan for the contract address.
Has anyone successfully forked PancakeSwap and gotten past this error?
I'm trying to fork It too and i've encountered the same error multiple time. You should check which function throw this error becouse the original cause can be a wrong farms or pools configuration. For example i've the same error throwed by useFetchBalances hooks and navigating through the stack i've seen that useCakeBnb/useCakeBusd cause the problem too, so i've configured pools and now It works fine.
I Hope that this can be helpfull for you

AMDeviceValidatePairing failed

While using Fruitstrap (or some other tools which uses MobileDevice.h) for installation of apps, we come across this error:
AMDeviceValidatePairing failed
How to solve this in MAC?
So if you are using fruitstrap, it actually uses MobileDevice.h for accessing the MobileDevice.framework. MobileDevice.framework is actually contacting iTunes and doing the required process. In between it opens up a process and fails to terminate:
/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/Resources/usbmuxd -launchd
On terminating this process, it will solve the problem and AMDeviceValidatePairing will succeed.
I encountered the same error in fruitstrap.
My problem was that iTunes was not authorized to access data from my mobile(since I had just update to 7.1.1).
So I opened iTunes once, gave authorize in the dialog which opened. In the device a popup asked me if I wanted to "Trust this computer". Once I gave yes, I got this error no more.

Possible issues with sqlite3_mutex_enter(v->db->mutex) on cocoa c

I have an issue with the sqlite3_mutex_enter(v->db->mutex) error message on an iOS application.
The case is the following: I developed an application that is performing a sync on the application in the background while starting up. All SQL Statements that invoke writing to the DB are protected using a NSLOCK and are unlocked after the finalize.
Now the problem is, that the Application User can start working with the application while the sync is still ongoing. Sometimes I do get now an sqlite3_mutex_enter(v->db->mutex) when something is done on the DB level, sometimes it simply works. The cases where this error appears is mainly in read statements.
Do you have any ideas when the sqlite3_mutex_enter(v->db->mutex) error can show up? All statements are finalized properly. Something really weird is, that the SQLITE DB tries to close itself even if there is no command that tells the DB connection to close.
The statement sqlite3_mutex_enter(v->db->mutex) occurs only inside sqlite3_reset. An error in this place is likely to be caused by an invalid statement pointer, probably one that is already finalized.

Resources