* How to trap an error when connecting to a news server
@ 2020-01-04 14:01 gnus via info-gnus-english
2020-01-04 19:08 ` Bob Newell
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: gnus via info-gnus-english @ 2020-01-04 14:01 UTC (permalink / raw)
To: info-gnus-english
[-- Attachment #1.1: Type: text/plain, Size: 1172 bytes --]
I have this code:
(defun news-check ()
(message "The result is %d" (gnus-group-get-new-news))
)
(defun news-update ()
(interactive)
(setq quit-for t)
(while (eq quit-for t) ;; this stops if a key is pressed
(setq nnnn 0) ;; This counts seconds and displays them
(while (and (< nnnn 600) (eq t quit-for))
(setq quit-for (sit-for 1)) ;; wait for a second, or a key
(message "count %s" nnnn)
(setq nnnn (+ 1 nnnn))
)
(message "checking...")
(news-check) ;; this calls the above news check
)
)
If the server closes the connection, then this while loop stops. How can
I trap the error and continue the loop so that it tries again in 600
seconds?
I have tried using the condition-case mentioned in the manual but it
seemed to have no effect:
(defun news-check ()
(condition-case err
(message "The result is %s" (gnus-group-get-new-news))
(news-error
(message "I expect the server closed again %s",err)
)
)
)
Sorry if you see this more than once. I posted it to the newsgroup but now I
suspect the newsgroup is read-only.
Sent with Criptext secure email[https://api.criptext.com/email/open/%3C1578146518407.757655%40criptext.com%3E]
[-- Attachment #1.2: Type: text/html, Size: 1983 bytes --]
[-- Attachment #2: Type: text/plain, Size: 162 bytes --]
_______________________________________________
info-gnus-english mailing list
info-gnus-english@gnu.org
https://lists.gnu.org/mailman/listinfo/info-gnus-english
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to trap an error when connecting to a news server
2020-01-04 14:01 How to trap an error when connecting to a news server gnus via info-gnus-english
@ 2020-01-04 19:08 ` Bob Newell
2020-01-04 19:31 ` gnus via info-gnus-english
2020-01-04 20:20 ` gnus via info-gnus-english
2 siblings, 0 replies; 4+ messages in thread
From: Bob Newell @ 2020-01-04 19:08 UTC (permalink / raw)
To: gnus; +Cc: info-gnus-english
[-- Attachment #1.1: Type: text/plain, Size: 554 bytes --]
>
>
> (defun news-check ()
> (condition-case err
> (message "The result is %s" (gnus-group-get-new-news))
> (news-error
> (message "I expect the server closed again %s",err)
> )
> )
> )
>
> I could be mistaken in this, but in your code above, where did you get
> 'news-error' as the name of the error condition raised? I can't find this
> anywhere in the gnus source tree. Do you know for sure that
> gnus-group-get-new-news (or anything it calls) raises that condition?
--
Bob Newell
Honolulu, Hawai`i
Via Linux/Emacs/Gnus/BBDB.
[-- Attachment #1.2: Type: text/html, Size: 1040 bytes --]
[-- Attachment #2: Type: text/plain, Size: 162 bytes --]
_______________________________________________
info-gnus-english mailing list
info-gnus-english@gnu.org
https://lists.gnu.org/mailman/listinfo/info-gnus-english
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: How to trap an error when connecting to a news server
2020-01-04 14:01 How to trap an error when connecting to a news server gnus via info-gnus-english
2020-01-04 19:08 ` Bob Newell
@ 2020-01-04 19:31 ` gnus via info-gnus-english
2020-01-04 20:20 ` gnus via info-gnus-english
2 siblings, 0 replies; 4+ messages in thread
From: gnus via info-gnus-english @ 2020-01-04 19:31 UTC (permalink / raw)
To: bobnewell; +Cc: info-gnus-english
[-- Attachment #1.1: Type: text/plain, Size: 1671 bytes --]
On Sat, 4 Jan 2020 at 7:09 PM, Bob Newell < bobnewell@bobnewell.net > wrote:> >
(defun news-check ()
(condition-case err
(message "The result is %s" (gnus-group-get-new-news))
(news-error
(message "I expect the server closed again %s",err)
)
)
)
I could be mistaken in this, but in your code above, where did you get
'news-error' as the name of the error condition raised? I can't find this
anywhere in the gnus source tree. Do you know for sure that
gnus-group-get-new-news (or anything it calls) raises that condition?
Thank you for your response. It is useful to me that you ask this. I could not
tell from the manual that "arith-error" in the example had a specific meaning,
so I arbitrarily changed it.
https://www.gnu.org/software/emacs/manual/html_node/elisp/Handling-Errors.html
How do I tell what the error condition will be? The code in nntp.el is this (I
think this is where the server closed condition occurs) :
(defun nntp-report (&rest args)
"Report an error from the nntp backend. The first string in ARGS
can be a format string. For some commands, the failed command may be
retried once before actually displaying the error report."
(if nntp--report-1
(progn
;; Throw out to nntp-with-open-group-error so that the connection may
;; be restored and the command retried."
(when nntp-record-commands
(nntp-record-command "*** CONNECTION LOST ***"))
(throw 'nntp-with-open-group-error t))
(when nntp-record-commands
(nntp-record-command "*** CALLED nntp-report ***"))
(nnheader-report 'nntp args)
(apply 'error args)
))
[https://api.criptext.com/email/open/%3C1578166265275.914646%40criptext.com%3E]
[-- Attachment #1.2: Type: text/html, Size: 16763 bytes --]
[-- Attachment #2: Type: text/plain, Size: 162 bytes --]
_______________________________________________
info-gnus-english mailing list
info-gnus-english@gnu.org
https://lists.gnu.org/mailman/listinfo/info-gnus-english
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: How to trap an error when connecting to a news server
2020-01-04 14:01 How to trap an error when connecting to a news server gnus via info-gnus-english
2020-01-04 19:08 ` Bob Newell
2020-01-04 19:31 ` gnus via info-gnus-english
@ 2020-01-04 20:20 ` gnus via info-gnus-english
2 siblings, 0 replies; 4+ messages in thread
From: gnus via info-gnus-english @ 2020-01-04 20:20 UTC (permalink / raw)
To: bobnewell; +Cc: info-gnus-english, bobnewell
[-- Attachment #1.1: Type: text/plain, Size: 405 bytes --]
The backtrace shows this:
Debugger entered--Lisp error: (error "Server closed connection")
signal(error ("Server closed connection"))
error("Server closed connection")
apply(error "Server closed connection")
nntp-report("Server closed connection")
nntp-accept-process-output(#<process nntpd>)
nntp-accept-response()
[https://api.criptext.com/email/open/%3C1578169214432.258587%40criptext.com%3E]
[-- Attachment #1.2: Type: text/html, Size: 592 bytes --]
[-- Attachment #2: Type: text/plain, Size: 162 bytes --]
_______________________________________________
info-gnus-english mailing list
info-gnus-english@gnu.org
https://lists.gnu.org/mailman/listinfo/info-gnus-english
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-01-04 20:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-04 14:01 How to trap an error when connecting to a news server gnus via info-gnus-english
2020-01-04 19:08 ` Bob Newell
2020-01-04 19:31 ` gnus via info-gnus-english
2020-01-04 20:20 ` gnus via info-gnus-english
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).