@@ -179,26 +179,41 @@ result of this function to cancel its subscription with the
179179publisher providing content."
180180 (list 'unsubscribe ))
181181
182+ (define-error 'jupyter-publisher-subscribers-had-errors
183+ " Publisher's subscribers had errors" )
184+
182185(defun jupyter-pseudo-bind-content (pub-fn content subs )
183186 " Apply PUB-FN on submitted CONTENT to produce published content.
184187Call each subscriber in SUBS on the published content. Remove
185188those subscribers that cancel their subscription.
186189
187- Errors signaled by a subscriber are demoted to messages."
190+ When a subscriber signals an error it is noted and the remaining
191+ subscribers are processed. After processing all subscribers, a
192+ `jupyter-publisher-errors' error is raised with the data being
193+ the list of errors raised when calling subscribers. Note, when a
194+ subscriber errors, it remains in the list of subscribers."
188195 (pcase (funcall pub-fn content)
189196 ((and `(content , _ ) sub-content)
190197 ; ; NOTE: The first element of SUBS is ignored here so that the
191198 ; ; pointer to the subscriber list remains the same for each
192199 ; ; publisher, even when subscribers are being destructively
193200 ; ; removed.
194- (while (cadr subs)
195- (with-demoted-errors " Jupyter: I/O subscriber error: %S"
196- ; ; Publish subscriber content to subscribers
197- (pcase (funcall (cadr subs) sub-content)
198- ; ; Destructively remove the subscriber when it returns an
199- ; ; unsubscribe value.
200- ('(unsubscribe) (setcdr subs (cddr subs)))
201- (_ (pop subs)))))
201+ (let ((errors nil ))
202+ (while (cadr subs)
203+ (condition-case err
204+ ; ; Publish subscriber content to subscribers
205+ (pcase (funcall (cadr subs) sub-content)
206+ ; ; Destructively remove the subscriber when it returns an
207+ ; ; unsubscribe value.
208+ ('(unsubscribe) (setcdr subs (cddr subs)))
209+ (_ (pop subs)))
210+ (error
211+ ; ; Skip over any subscribers that raised an error.
212+ (pop subs)
213+ (push err errors))))
214+ ; ; Inform about the errors.
215+ (when errors
216+ (signal 'jupyter-publisher-subscribers-had-errors errors)))
202217 nil )
203218 ; ; Cancel a publisher's subscription to another publisher.
204219 ('(unsubscribe) '(unsubscribe))
0 commit comments