Leslie P. Polzer  committed d75d4ce

GEN-ID amendment.

  • Participants
  • Parent commits ffa9ad1
  • Branches default

Comments (0)

Files changed (1)

File src/utils/misc.lisp

 (defun gen-id (&optional (prefix ""))
   "Generates an ID unique accross the session. The generated ID can be
 used to create IDs for html elements, widgets, etc."
-  (let ((new-widget-id (1+ (or (session-value 'last-unique-id) -1))))
-    (setf (session-value 'last-unique-id) new-widget-id)
-    (format nil "~A~A" prefix new-widget-id)))
+  (handler-case
+      (let ((new-widget-id (1+ (or (session-value 'last-unique-id) -1))))
+        (setf (session-value 'last-unique-id) new-widget-id)
+        (format nil "~A~A" prefix new-widget-id))
+    (error (e)
+      (warn "Error generating a session-unique id (GEN-ID): ~A~%Returning a GENSYM id instead." e)
+      (princ-to-string (gensym prefix)))))
 (defgeneric humanize-name (name)
   (:documentation "Convert objects to a human-readable string suitable