From 014755780f6122995289b7bd92e20e979cfe4237 Mon Sep 17 00:00:00 2001 From: Stelian Ionescu Date: Sat, 24 Jan 2009 20:54:29 +0100 Subject: [PATCH] Improve error hierarchy. --- syscalls/conditions.lisp | 32 ++++++++++++++++++-------------- syscalls/pkgdcl.lisp | 6 +++--- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/syscalls/conditions.lisp b/syscalls/conditions.lisp index 174b079..a76118e 100644 --- a/syscalls/conditions.lisp +++ b/syscalls/conditions.lisp @@ -9,18 +9,24 @@ ;;; System Errors ;;;------------------------------------------------------------------------- -(define-condition condition-info-mixin (condition) +(define-condition iolib-condition () + ()) + +(define-condition iolib-error (error iolib-condition) + ()) + +(define-condition syscall-error (iolib-error) ((code :initarg :code :reader code-of :documentation "Numeric error code, or NIL.") (identifier :initarg :identifier :reader identifier-of :documentation "Keyword identifier, or NIL.") (message :initarg :message :reader message-of - :documentation "Error description.")) - (:default-initargs :code nil :identifier :unknown :message nil)) - -(define-condition syscall-error (error condition-info-mixin) - ((handle :initform nil :initarg :handle :reader handle-of) - (handle2 :initform nil :initarg :handle2 :reader handle2-of)) + :documentation "Error description.") + (handle :initform nil :initarg :handle :reader handle-of + :documentation "The OS handle involved in the error situation.") + (handle2 :initform nil :initarg :handle2 :reader handle2-of + :documentation "An optional second OS handler.")) + (:default-initargs :code nil :identifier :unknown :message nil) (:documentation "Base class for syscall errors.")) (defun syscall-error (control-string &rest args) @@ -32,23 +38,21 @@ ;;;------------------------------------------------------------------------- (define-condition poll-error (syscall-error) - ((event-type :initarg :event-type :reader event-type-of) - (os-handle :initarg :os-handle :reader os-handle-of)) + ((event-type :initarg :event-type :reader event-type-of)) (:report (lambda (c s) (format s "Poll error(event ~S, handle ~A)" - (event-type-of c) (os-handle-of c)) + (event-type-of c) (handle-of c)) (when (message-of c) (format s ": ~A" (message-of c))))) (:documentation "Signaled when an error occurs while polling for I/O readiness of a file descriptor.")) -(define-condition poll-timeout (condition-info-mixin) - ((event-type :initarg :event-type :reader event-type-of) - (os-handle :initarg :os-handle :reader os-handle-of)) +(define-condition poll-timeout (poll-error) + () (:report (lambda (c s) (format s "Poll timeout(event ~S, handle ~A)" - (event-type-of c) (os-handle-of c)) + (event-type-of c) (handle-of c)) (when (message-of c) (format s ": ~A" (message-of c))))) (:documentation diff --git a/syscalls/pkgdcl.lisp b/syscalls/pkgdcl.lisp index d3688ca..ef2114c 100644 --- a/syscalls/pkgdcl.lisp +++ b/syscalls/pkgdcl.lisp @@ -10,8 +10,10 @@ (:use :iolib.base :cffi) (:export ;; Conditions - #:condition-info-mixin + #:iolib-condition + #:iolib-error #:syscall-error + #:make-syscall-error #:poll-error #:poll-timeout @@ -22,7 +24,6 @@ #:handle-of #:handle2-of #:event-type-of - #:os-handle-of #:get-syscall-error-condition ;; Pathname Functions @@ -51,7 +52,6 @@ #:syscall-restart-p #:base-type-of #:never-fails - #:make-syscall-error #:signal-syscall-error #:signal-syscall-error-kw #:signal-syscall-error/restart -- 2.11.4.GIT