You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In #216, I mentioned about adding throws to the operation block for ReactiveExtensions. However you added throws in the wrong place so that the signature of operation is now:
In the first, and currently released version, the throws is on the save block but the save block doesn't and shouldn't throw. The docs clearly state that the save parameter is called like save but if save throws then it has to be called as try save, inside an operation block that ALSO throws.
Take the following example:
return self.storage.operation{ context, save intry context.insert(model)save()}
Because save is marked as throws now, the compiler errors out saying can call throw, but it not marked with 'try' and the error is not handled. And since the operation block doesn't throw, try context won't work because it's inside a non-throwing closure.
What I think you want is for the save block AND the operation block to throws, which would result in:
@startupthekid thanks for reporting it. I agree with you. These are the changes I introduced on this #223 PR:
Operation closure now throws. Developers can use context operations that throw using just try without catching the error inside the operation closure.
If there's an error thrown inside that closure, either because of a developer operation or the save block throws it, this is going to be forwared up to the operation throwing.
In case of the reactive interface. When something throws an error, it's sent as an error through the Reactive stream.
In #216, I mentioned about adding
throws
to the operation block for ReactiveExtensions. However you added throws in the wrong place so that the signature ofoperation
is now:when it should be:
In the first, and currently released version, the
throws
is on the save block but the save block doesn't and shouldn't throw. The docs clearly state that the save parameter is called likesave
but if save throws then it has to be called astry save
, inside an operation block that ALSO throws.Take the following example:
Because save is marked as
throws
now, the compiler errors out sayingcan call throw, but it not marked with 'try' and the error is not handled
. And since the operation block doesn't throw,try context
won't work because it's inside a non-throwing closure.What I think you want is for the save block AND the operation block to throws, which would result in:
Then the consumer of the operation function would use it like:
where the error thrown would be caught by the operation block.
In
RealmDefaultStorage
, that would look something like:The text was updated successfully, but these errors were encountered: