Provide a way to fail gracefully on errors, and use it in irc.scm
[8sync.git] / eightsync / systems / irc.scm
index e45db1a7c5b81be378a8327ccf4142c058be25d4..0907bcdd21e36594b5197c599af12b8e381e5250 100755 (executable)
     (channels (value #t))
     (listen)))
 
-(define* (make-irc-bot-cli #:optional (line-handler default-line-handler))
+(define* (make-irc-bot-cli #:optional
+                           (line-handler default-line-handler)
+                           (print-and-continue-on-error #t))
   (define (main args)
     (let* ((options (getopt-long args option-spec))
            (hostname (option-ref options 'server #f))
            (username (option-ref options 'username #f))
            (listen (option-ref options 'listen #f))
            (channels (option-ref options 'channels ""))
-           (agenda (make-agenda)))
+           (agenda (if print-and-continue-on-error
+                       (make-agenda #:pre-unwind-handler print-error-and-continue)
+                       (make-agenda))))
       (display `((server ,hostname) (port ,port) (username ,username)
                  (listen ,listen) (channels-split ,(string-split channels #\space))))
       (newline)
   main)
 
 (define main (make-irc-bot-cli))
-