Skip to content

Commit 12cbba2

Browse files
committed
Add exception handling if not found darkmatter log file
1 parent c4c74ab commit 12cbba2

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

src/process.lisp

+21-14
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@
7070
(let ((files (directory (format nil "~A*" dir))))
7171
(car (last files))))))
7272

73+
(define-condition darkmatter-log-file-not-found (error)
74+
((text :initarg :text :reader text)))
75+
7376
(defun make-server-process (tbl hostname id)
7477
(let* ((proc-table (gethash hostname tbl))
7578
(log-count (%count-darkmatter-log-files))
@@ -83,21 +86,25 @@
8386
(force-output))
8487
(terpri)
8588
(setf path (%get-darkmatter-log-file))
86-
(with-open-file (in path :direction :input)
87-
(tagbody
88-
start
89+
(if (null path)
90+
(error 'darkmatter-log-file-not-found
91+
:text "Not found log file. Make sure work Darkmatter correctly.")
8992
(progn
90-
(loop for line = (read-line in nil)
91-
do (setf port (%parse-port-number line))
92-
until (numberp port))
93-
(when (let ((line (read-line in nil)))
94-
(and (stringp line)
95-
(%parse-failure line)))
96-
(go start)))
97-
finish))
98-
(sleep 1)
99-
(setf (gethash id proc-table)
100-
(make-instance 'server-process :entity entity :port port))
93+
(with-open-file (in path :direction :input)
94+
(tagbody
95+
start
96+
(progn
97+
(loop for line = (read-line in nil)
98+
do (setf port (%parse-port-number line))
99+
until (numberp port))
100+
(when (let ((line (read-line in nil)))
101+
(and (stringp line)
102+
(%parse-failure line)))
103+
(go start)))
104+
finish))
105+
(sleep 1)
106+
(setf (gethash id proc-table)
107+
(make-instance 'server-process :entity entity :port port))))
101108
port))
102109

103110
(defun delete-server-process-table (tbl)

0 commit comments

Comments
 (0)