Permalink
Browse files

Added sanity check to rudel-{join, host}-session

* rudel-errors.el (rudel-incomplete-info): new error symbol
* rudel.el (rudel-join-session): added sanity checks for info argument
  (rudel-host-session): added sanity checks for info argument
  • Loading branch information...
1 parent cedcad6 commit 5386af8d1d873a7537d385be60c831972d609fa9 @scymtym committed Jan 10, 2010
Showing with 31 additions and 6 deletions.
  1. +18 −6 rudel-errors.el
  2. +13 −0 rudel.el
View
24 rudel-errors.el
@@ -1,9 +1,9 @@
;;; rudel-errors.el --- Error data used in Rudel
;;
-;; Copyright (C) 2009 Jan Moringen
+;; Copyright (C) 2009, 2010 Jan Moringen
;;
;; Author: Jan Moringen <scymtym@users.sourceforge.net>
-;; Keywords: Rudel, errors, conditions
+;; Keywords: rudel, errors, conditions
;; X-RCS: $Id:$
;;
;; This file is part of Rudel.
@@ -27,19 +27,31 @@
;; The following condition hierarchy is defined:
;;
;; error
-;; +- rudel-error
-;; +- rudel-join-error
-;; +- rudel-host-error
+;; + rudel-error
+;; + rudel-incomplete-info
+;; + rudel-join-error
+;; + rudel-host-error
;;; History:
;;
-;; 0.1 - Initial revision
+;; 0.1 - Initial version
;;; Code:
;;
+;; rudel-incomplete-info
+
+(intern "rudel-incomplete-info")
+
+(put 'rudel-incomplete-info 'error-conditions
+ '(error
+ rudel-error rudel-incomplete-info))
+
+(put 'rudel-incomplete-info 'error-message
+ "Required properties missing in property list")
+
;; rudel-join-error
(intern "rudel-join-error")
View
13 rudel.el
@@ -814,6 +814,14 @@ will be prompted for."
(setq info maybe-info))))
info)))
+ ;; Some sanity checks on INFO.
+ (unless (member :name info)
+ (setq info (plist-put info :name "rudel session")))
+
+ (dolist (property '(:transport-backend :protocol-backend))
+ (unless (member property info)
+ (signal 'rudel-incomplete-info (list property))))
+
;; First, create the session object.
(let* ((session-name (plist-get info :name))
(transport-backend (cdr (plist-get info :transport-backend)))
@@ -878,6 +886,11 @@ will be prompted for."
(list :transport-backend transport-backend
:protocol-backend protocol-backend)))))
+ ;; Some sanity checks on INFO.
+ (dolist (property '(:transport-backend :protocol-backend))
+ (unless (member property info)
+ (signal 'rudel-incomplete-info (list property))))
+
;; Create the session object.
(let ((transport-backend (cdr (plist-get info :transport-backend)))
(protocol-backend (cdr (plist-get info :protocol-backend)))

0 comments on commit 5386af8

Please sign in to comment.