Update exception handling for build events

This commit is contained in:
Christopher Baines 2025-04-01 22:43:15 +03:00
parent d60a8a44cb
commit 14de1667b1

View file

@ -277,8 +277,15 @@
(if (member provided-token
(map cdr permitted-tokens)
string=?)
(catch
'json-invalid
(with-exception-handler
(lambda (exn)
(if (eq? (exception-kind exn) 'json-invalid)
(render-json
'((error . "could not parse body as JSON"))
#:code 400)
(render-json
'((error . "error"))
#:code 403)))
(lambda ()
(let ((body-string (utf8->string body)))
(let* ((body-json (json-string->scm body-string))
@ -294,30 +301,27 @@
'((error . "no items to process"))
#:code 400))
(else
(catch
#t
(with-exception-handler
(lambda (exn)
(render-json
'((error . "could not process events"))
#:code 500))
(lambda ()
(process-items items)
(with-exception-handler
(lambda (exn)
(print-backtrace-and-exception/knots exn)
(simple-format (current-error-port)
"error processing events: ~A\n"
exn)
(for-each (lambda (item)
(simple-format (current-error-port)
" ~A\n" item))
items))
(lambda ()
(process-items items)))
(no-content))
(lambda (key . args)
(simple-format (current-error-port)
"error processing events: ~A: ~A\n"
key
args)
(for-each (lambda (item)
(simple-format (current-error-port)
" ~A\n" item))
items)
(render-json
'((error . "could not process events"))
#:code 500))))))))
(lambda (key . args)
(render-json
'((error . "could not parse body as JSON"))
#:code 400)))
(render-json
'((error . "error"))
#:code 403)))))))
#:unwind? #t))))))
#:unwind? #t)))))))
(define (handle-signing-key-request id)
(render-html