X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=pubmed.lisp;h=3def005a566c604434489818476fe4774b7f3bec;hb=8f8c17ab7068ef5991595d678d9d2cc767a8b5bf;hp=c20d11138bfb04c8299a8fae9b3bc5992ae52e12;hpb=dc450ece8ff68c4a459fd47654c11ab28ddc0cc5;p=pubmed.git
diff --git a/pubmed.lisp b/pubmed.lisp
index c20d111..3def005 100644
--- a/pubmed.lisp
+++ b/pubmed.lisp
@@ -7,7 +7,7 @@
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Jun 2001
;;;;
-;;;; $Id: pubmed.lisp,v 1.3 2002/10/31 19:42:26 kevin Exp $
+;;;; $Id: pubmed.lisp,v 1.6 2002/10/31 21:37:56 kevin Exp $
;;;;
;;;; This file, part of cl-pubmed, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
@@ -26,6 +26,7 @@
;; Conditions
#:pubmed-condition
+ #:pubmed-query-error
#:pubmed-server-error
;; Query functions
@@ -81,6 +82,15 @@
(format stream "A PubMed server error occurred.")
(awhen (pubmed-server-error-response c)
(format stream " The server response was:~&~S" it)))))
+
+(define-condition pubmed-query-error (error pubmed-condition)
+ ((response :initarg :response
+ :initform nil
+ :reader pubmed-query-error-response))
+ (:report (lambda (c stream)
+ (format stream "A PubMed server error occurred.")
+ (awhen (pubmed-server-query-response c)
+ (format stream " The server response was:~&~S" it)))))
;;; Article-Set and Article Classes
@@ -119,7 +129,8 @@
(defmethod print-object ((obj pm-article) (s stream))
(print-unreadable-object (obj s :type t :identity t)
- (format s "pmid: ~d" (article-pmid obj))))
+ (format s "pmid:~d, title:~S" (article-pmid obj)
+ (article-title obj))))
(defun article-equal-p (a b)
(check-type a pm-article)
@@ -144,44 +155,47 @@
"Display an article set to specified stream in specified format"
(dotimes (i (articles-count artset))
(print-article (nth i (articles artset)) :os os :format format
- :complete complete :print-link print-link)))
+ :complete complete :print-link print-link))
+ artset)
(defmethod print-article ((art pm-article) &key (os *standard-output*) (format :text)
(complete nil) (print-link t))
"Display an article"
- (if (eql format :text)
- (format os "~a~%~a~%~a~a ~a~%~a~%"
- (article-title art)
- (list-to-delimited-string (article-authors art) ", ")
- (aif (article-affiliation art)
- (format nil "~a~%" it) "")
- (article-journal art) (article-ref art)
- (aif (article-abstract art)
+ (ecase format
+ (:text
+ (format os "~a~%~a~%~a~a ~a~%~a~%"
+ (article-title art)
+ (list-to-delimited-string (article-authors art) ", ")
+ (aif (article-affiliation art)
+ (format nil "~a~%" it) "")
+ (article-journal art) (article-ref art)
+ (aif (article-abstract art)
(if complete
it
"Abstract available")
- "No abstract available")
- (when complete
- (format os "~a~%" (article-mesh-headings art))))
-
- (let ((has-link (or (article-abstract art) (article-mesh-headings art))))
- (when (and print-link has-link)
- (format os "" (make-url "print-article") (article-pmid art)))
- (format os "