Changeset 15852 in project


Ignore:
Timestamp:
09/13/09 13:28:02 (10 years ago)
Author:
sjamaan
Message:

Add more detailed error information to errors detected client-side

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/4/estraier-client/estraier-client.scm

    r15851 r15852  
    5656    (if (eof-object? line) (void) (loop (read-line in)))))
    5757
    58 (define (http->estraier-exn exn loc specific . rest)
     58(define (estraier-exn loc message specific . rest)
    5959  (make-composite-condition
    60    (make-property-condition
    61     'exn 'location loc
    62     'message ((condition-property-accessor 'exn 'message) exn))
     60   (make-property-condition 'exn 'location loc 'message message)
    6361   (make-property-condition 'estraier-client)
    6462   (apply make-property-condition specific rest)))
     63
     64(define (http->estraier-exn exn loc specific . rest)
     65  (estraier-exn loc ((condition-property-accessor 'exn 'message) exn)))
    6566
    6667(define (exec loc uri writer reader)
     
    9899
    99100;; Helper procedure for checking that id xor uri is supplied
    100 (define (id/uri->alist id uri)
     101(define (id/uri->alist loc id uri)
    101102  (cond
    102103   ((and id (not uri)) `((id . ,id)))
    103104   ((and uri (not id)) `((uri . ,uri)))
    104    (else (error "You must supply either an id or a uri"))))
     105   (else
     106    (signal (estraier-exn loc "You must supply either an id or a uri" 'args)))))
    105107
    106108;;;; Node API
     
    201203(define (delete-document base-uri node #!key id uri)
    202204  (exec 'delete-document
    203         (node-uri base-uri node "out_doc" query: (id/uri->alist id uri))
     205        (node-uri base-uri node "out_doc"
     206                  query: (id/uri->alist 'delete-document id uri))
    204207        #f discard-output))
    205208
     
    213216         (exec
    214217          'get-document
    215           (node-uri base-uri node "get_doc" query: (id/uri->alist id uri))
     218          (node-uri base-uri node "get_doc"
     219                    query: (id/uri->alist 'get-document id uri))
    216220          #f (lambda (in)
    217221               (call-with-values (lambda () (read-draft in)) list)))))
     
    235239  (exec 'document-attribute
    236240        (node-uri base-uri node "get_doc_attr"
    237                   query: (cons `(attr . ,attrib) (id/uri->alist id uri)))
     241                  query: (cons `(attr . ,attrib)
     242                               (id/uri->alist 'document-attribute id uri)))
    238243        #f read-line))
    239244
    240245(define (document-keywords base-uri node #!key id uri)
    241246  (exec 'document-keywords
    242         (node-uri base-uri node "etch_doc" query: (id/uri->alist id uri))
     247        (node-uri base-uri node "etch_doc"
     248                  query: (id/uri->alist 'document-keywords id uri))
    243249        #f
    244250        (lambda (in)
     
    258264                        wwidth hwidth awidth skip mask)
    259265  (when (> (length attr-phrases) 10)
    260     (error (string-append "You can't provide more than 10 attribute phrases. "
    261                           "This is a limitation of the estraier API. Sorry!")))
     266    (signal
     267     (estraier-exn 'find-documents
     268                   (conc "You can't provide more than 10 attribute phrases. "
     269                         "This is a limitation of the estraier API. Sorry!")
     270                   'args)))
    262271  ;; Normalise attr-phrases list to attr, attr1, ... attr9
    263272  (let ((attrs (map (lambda (a i)
Note: See TracChangeset for help on using the changeset viewer.