Skip to content

Commit 75b2e35

Browse files
committed
store errno in SIMPLE-FILE-ERROR conditions
CCL signals SIMPLE-FILE-ERROR conditions for all file-related errors, but they do not contain any information to programmatically distinguish what the error actually is. The most basic use case is the ability to detect that opening a file failed because it does not exist. Without this patch, it is impossible to make the difference between a file-not-found error and for example an IO error.
1 parent ff51228 commit 75b2e35

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

level-1/l1-error-signal.lisp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
(format-string (if errargs
4646
(format nil "~a : ~a" error-string "~s")
4747
error-string)))
48-
(%err-disp-common nil err-type format-string errargs frame-ptr)))
48+
(%err-disp-common errno err-type format-string errargs frame-ptr)))
4949

5050

5151
(defun %err-disp-internal (err-num errargs frame-ptr)
@@ -87,7 +87,8 @@
8787
(simple-file-error (make-condition condition-name
8888
:pathname (car errargs)
8989
:error-type format-string
90-
:format-arguments (cdr errargs)))
90+
:format-arguments (cdr errargs)
91+
:errno err-num))
9192
(undefined-function (make-condition condition-name
9293
:name (car errargs)))
9394
(call-special-operator-or-macro

level-1/l1-error-system.lisp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,11 @@
580580
(file-error-pathname c)))))
581581

582582
(define-condition simple-file-error (simple-condition file-error)
583-
()
583+
((errno
584+
:type (or integer null)
585+
:initarg :errno
586+
:initform nil
587+
:reader simple-file-error-errno))
584588
(:report (lambda (c s)
585589
(apply #'format s (slot-value c 'error-type)
586590
(file-error-pathname c)

0 commit comments

Comments
 (0)