Commit 46853c4b93df79686f0aac10b34d92a7aad29eba

Thomas de Grivel 2017-06-27T18:03:21

condition

diff --git a/cffi-errno.lisp b/cffi-errno.lisp
index 38d9a80..c833e28 100644
--- a/cffi-errno.lisp
+++ b/cffi-errno.lisp
@@ -24,5 +24,21 @@
 (defun strerror (errnum)
   (c-strerror errnum))
 
-(defun error-errno (msg)
-  (error "~A: ~D ~A" msg errno (strerror errno)))
+(define-condition errno-error (error)
+  ((message :initarg :message
+            :reader errno-error-message)
+   (errno :initarg :errno
+          :reader errno-error-errno)
+   (strerror :initarg :strerror
+             :reader errno-error-strerror))
+  (:report (lambda (condition stream)
+             (format stream "~A: ~D ~A"
+                     (errno-error-message condition)
+                     (errno-error-errno condition)
+                     (errno-error-strerror condition)))))
+
+(defun error-errno (message)
+  (error 'errno-error
+         :message message
+         :errno errno
+         :strerror (strerror errno)))
diff --git a/package.lisp b/package.lisp
index 9343168..22264e8 100644
--- a/package.lisp
+++ b/package.lisp
@@ -23,6 +23,10 @@
   (:use :common-lisp :cffi)
   (:export
    #:errno
+   #:errno-error
+   #:errno-error-errno
+   #:errno-error-message
+   #:errno-error-strerror
    #:error-errno
    #:strerror
    #:+eperm+