summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandom Hacker <random_hacker@xapek.org>2012-03-06 15:43:32 +0100
committerRandom Hacker <random_hacker@xapek.org>2012-03-06 15:43:32 +0100
commitb79a5a8ab011e8b4ee3a9adb3b1085a6acd0f482 (patch)
tree74c41ae68b1601dc0aeadfdefd64fed5f752466d
parent86c167acc082328cae11ae5f845d41967689e184 (diff)
downloadebus-alt-b79a5a8ab011e8b4ee3a9adb3b1085a6acd0f482.tar.gz
ebus-alt-b79a5a8ab011e8b4ee3a9adb3b1085a6acd0f482.zip
ebus-racket: set db-default loglevel=warning; add exception handler in inserter
-rwxr-xr-xebus-racket/inserter.rkt18
1 files changed, 11 insertions, 7 deletions
diff --git a/ebus-racket/inserter.rkt b/ebus-racket/inserter.rkt
index bd23e04..ab90911 100755
--- a/ebus-racket/inserter.rkt
+++ b/ebus-racket/inserter.rkt
@@ -13,23 +13,27 @@
(define connect-host? (make-parameter null))
(define connect-port? (make-parameter null))
(define loglevel-layer2? (make-parameter 'info))
-(define loglevel-db? (make-parameter 'info))
+(define loglevel-db? (make-parameter 'warning))
(define insert? (make-parameter #f))
(define (handle-fields fields)
(for ([field fields])
(log-message logger 'info (format "Field: ~a" field) #t)
(when (insert?)
- (apply db-insert-field field))))
+ (with-handlers ([exn:fail? (lambda (exn)
+ (log-message logger 'error (format "Failed to insert ~a: ~a" field exn) #t))])
+ (apply db-insert-field field)))))
(define (make-ebus-loop7 input-port)
(lambda ()
(let loop ()
- (let ([fields (layer7-read-ebus (current-input-port))])
- (when (not (or (void? fields) (eof-object? fields)))
- (handle-fields fields))
- (when (not (eof-object? fields))
- (loop))))))
+ (with-handlers ([exn:fail? (lambda (exn)
+ (log-message logger 'error (format "Failed to parse paket: ~a" exn) #t))])
+ (let ([fields (layer7-read-ebus (current-input-port))])
+ (when (not (or (void? fields) (eof-object? fields)))
+ (handle-fields fields))
+ (when (not (eof-object? fields))
+ (loop)))))))
;; Start Thread that observe all given log-receivers
(define (start-logger-thread receiver1 . receiverN)