The Inbox: Kernel-tonyg.1153.mcz

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

The Inbox: Kernel-tonyg.1153.mcz

A new version of Kernel was added to project The Inbox:

==================== Summary ====================

Name: Kernel-tonyg.1153
Author: tonyg
Time: 29 January 2019, 5:14:21.285019 pm
UUID: 66ed8c76-624e-4050-bdc2-045d694e8aca
Ancestors: Kernel-tonyg.1152

Improve promise resolution error handling via #fulfillWith:.

=============== Diff against Kernel-tonyg.1152 ===============

Item was added:
+ ----- Method: Promise>>fulfillWith: (in category 'resolving') -----
+ fulfillWith: aBlock
+ self fulfillWith: aBlock passErrors: rejecters isEmpty!

Item was added:
+ ----- Method: Promise>>fulfillWith:passErrors: (in category 'resolving') -----
+ fulfillWith: aBlock passErrors: aBoolean
+ "Evaluate aBlock. If it signals an exception, reject this promise with the exception
+ as the argument; if it returns a value [or another Promise], resolve this promise
+ with the result.
+ If aBoolean is true, and an exception is signaled, it is passed out to the caller.
+ If aBoolean is false, signaled exceptions are considered handled after the promise
+ has been rejected."
+ [ self resolveWith: aBlock value ]
+ on: Exception
+ do: [ :ex |
+ (ex isKindOf: Halt)
+ ifTrue: [ex pass]
+ ifFalse: [
+ self rejectWith: ex.
+ aBoolean ifTrue: [ ex pass ] ]]!