Failures handles invalid project name gracefully
authorFrank Duncan <frank@kank.net>
Sat, 18 Dec 2021 16:47:36 +0000 (10:47 -0600)
committerFrank Duncan <frank@kank.net>
Sat, 18 Dec 2021 16:47:36 +0000 (10:47 -0600)
src/main/server.lisp

index 035ba4ce164cc7dea5bd14ec243a6e9a21e01cd7..f086aa24242e4d55f6036c2e8cd08d9b2c94001b 100644 (file)
   *all-project*))
 
 (defun failures (project-name)
- (length
-  (remove-if-not
-   (lambda (branch) (eql :failed (job-status (branch-job branch))))
-   (if project-name
-     (find-branch-by-project
-      (find project-name *all-project* :test #'string= :key #'project-name))
-     *all-branch*))))
+ (let
+  ((project (when project-name (find project-name *all-project* :test #'string= :key #'project-name))))
+  (when (and project-name (not project)) (raise-candle-error :project-does-not-exist))
+  (length
+   (remove-if-not
+    (lambda (branch) (eql :failed (job-status (branch-job branch))))
+    (if project (find-branch-by-project project) *all-branch*)))))