[bknr-cvs] r2016 - branches/xml-class-rework/projects/bos/m2

bknr at bknr.net bknr at bknr.net
Fri Oct 20 21:39:18 UTC 2006


Author: hhubner
Date: 2006-10-20 17:39:18 -0400 (Fri, 20 Oct 2006)
New Revision: 2016

Modified:
   branches/xml-class-rework/projects/bos/m2/mail-generator.lisp
Log:
vcard generation with error handling


Modified: branches/xml-class-rework/projects/bos/m2/mail-generator.lisp
===================================================================
--- branches/xml-class-rework/projects/bos/m2/mail-generator.lisp	2006-10-20 20:06:11 UTC (rev 2015)
+++ branches/xml-class-rework/projects/bos/m2/mail-generator.lisp	2006-10-20 21:39:18 UTC (rev 2016)
@@ -118,33 +118,38 @@
 				    contract-id))))
 
 (defun worldpay-callback-request-to-vcard (request)
-  (with-query-params (request cartId
-			      transId
-			      MC_sponsorid
-			      MC_donationcert-yearly
-			      MC_gift
-			      name
-			      address
-			      postcode
-			      country
-			      email
-			      tel)
-    (with-output-to-string (s)
-      (format s "BEGIN:VCARD~%")
-      (format s "REV:~A~%" (format-date-time (get-universal-time) :xml-style t))
-      (format s "VERSION:2.1~%")
-      (format s "FN:~A~%" name)
-      (format s "ADR;DOM;HOME;ENCODING=QUOTED-PRINTABLE:;;~A;;;~A;~A~%" (regex-replace-all #?r"\r?\n" address "=0D=0A") postcode country)
-      (format s "TEL;WORK;HOME:~A~%" tel)
-      (format s "EMAIL;PREF;INTERNET:~A~%" email)
-      (format s "URL;WORK:~A/edit-sponsor/~A~%" worldpay-test::*website-url* MC_sponsorid)
-      (format s "NOTE:Contract ID: ~A  Sponsor ID: ~A  WorldPay Transaction ID: ~A  Donationcert yearly: ~A  Gift: ~A~%"
-	      cartId
-	      MC_sponsorid
-	      transId
-	      (if MC_donationcert-yearly "Yes" "No")
-	      (if MC_gift "Yes" "No"))
-      (format s "END:VCARD~%"))))
+  (handler-case 
+      (with-query-params (request cartId
+				  transId
+				  MC_sponsorid
+				  MC_donationcert-yearly
+				  MC_gift
+				  name
+				  address
+				  postcode
+				  countryString
+				  email
+				  tel)
+	(with-output-to-string (s)
+	  (format s "BEGIN:VCARD~%")
+	  (format s "REV:~A~%" (format-date-time (get-universal-time) :xml-style t))
+	  (format s "VERSION:2.1~%")
+	  (format s "FN:~A~%" name)
+	  (format s "ADR;DOM;HOME;ENCODING=QUOTED-PRINTABLE:;;~A;;;~@[~A~];~A~%" (regex-replace-all #?r"\r?\n" address "=0D=0A") postcode countryString)
+	  (when tel
+	    (format s "TEL;WORK;HOME:~A~%" tel))
+	  (format s "EMAIL;PREF;INTERNET:~A~%" email)
+	  (format s "URL;WORK:~A/edit-sponsor/~A~%" worldpay-test::*website-url* MC_sponsorid)
+	  (format s "NOTE:Contract ID: ~A  Sponsor ID: ~A  WorldPay Transaction ID: ~A  Donationcert yearly: ~A  Gift: ~A~%"
+		  cartId
+		  MC_sponsorid
+		  transId
+		  (if MC_donationcert-yearly "Yes" "No")
+		  (if MC_gift "Yes" "No"))
+	  (format s "END:VCARD~%")))
+    (error (e)
+      (warn "vcard could not be generated: ~A~%" e)
+      "")))
 
 (defun mail-request-parameters (req subject)
   (let ((mime (make-instance 'cl-mime:multipart-mime




More information about the Bknr-cvs mailing list