Rick Frankel <r...@rickster.com> writes: > On 2013-10-18 01:29, Nicolas Richard wrote: >> Rick Frankel <r...@rickster.com> writes: >> One small problem, should be =(1+ (point))=, as the above leaves a >> blank newline at the head of the jpg, making it invalid. >> >> Oops, yes [Initially I had (search-forward "\n\n"), which worked >> fine,... then changed my mind and didn't test. Silly me.] >> >> Your code downloaded two images easily, but >> (signal :error (cdr err)))) >> signals a weird error for me (something like: "error in >> process filter: if: peculiar error: http, 404"). I suggest: >> >> (error "Error fetching URL %s: %s" url (cdr err)) > > That seems fine. I was just following the suggestion in the doc string > for `url-retrieve'.
Indeed, it is bizarre because err contains e.g. (error http 404), which is claimed to be of the form ERROR-SYMBOL . DATA, but (car DATA) must be a string according to (info "(elisp) Signaling Errors") : ,---- | For `error', the error message is | the CAR of DATA (that must be a string). `---- > BTW, did you know that org already has a function which works > perfectly for this purpose (well, it's synchronous, but otherwise...) > `org-feed-get-feed'? No, I didn't know that (but I think doing things asynchronously has added value). > (let ((err (plist-get status :error))) > (if err (error > "\"%s\" %s." url > (downcase (nth 2 (assq (nth 2 err) url-http-codes)))))) Nice -- Nico.