all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: emacs-devel@gnu.org
Subject: Re: with-url
Date: Sat, 21 Jan 2017 23:26:07 +0300	[thread overview]
Message-ID: <e6b14926-f56c-55b0-3d7f-388fda9580ac@yandex.ru> (raw)
In-Reply-To: <87bmv0beoa.fsf@gnus.org>

On 21.01.2017 18:44, Lars Ingebrigtsen wrote:

> Nope.  You should only signal an error if you have an error, and getting
> a 404 isn't an error.

Whether 404 is an error or not, depends on an application. And I'm 
saying that as someone with a few years of experience writing web 
applications that do HTTP requests themselves.

Consider the case where an application calls a function foo (which 
implements some sort of abstraction layer), and the said function uses 
with-url.

If foo is supposed to be general purpose (used in different 
applications), it would have to handle errors in a general way, so that 
any of its callers could still handle any kinds of errors, without being 
a macro. I'd rather with-url (or its replacement) was an example of 
doing that already.

>> Something else I take an issue with, is with `with-url' being a
>> macro. :) That violates The First Rule of Macro Club.
>
> Yes, the first rule is "use a macro when it makes sense".

Not really. And macros make sense the most when we add a control flow 
construct, or some sort of definition syntax for a new facility. Neither 
of which is really the case here.

You're basically joining a library function with a control flow 
construct together.

>> 2) Basically require to use the newly-introduced threads for
>> asynchrony.
>
> Using the new threads is a trivial rewrite and doesn't affect the
> signature of the macro.

It could simplify it, by allowing to treat asynchronous code like 
synchronous one.

> Anyway, I think the best option here would be to just have an
> :ignore-errors parameter to `with-url'.  In that case, the body will
> just be evaluated if we get non-error response.

I'm rather more worried about being able to handle errors in an 
asynchronous fashion.

You could say 404 is not an error, but handling it in a similar way to 
all other "actual" errors like "can't resolve the hostname" and 
"connection timeout" can be pretty handy.



  reply	other threads:[~2017-01-21 20:26 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-29  0:41 with-url Lars Ingebrigtsen
2016-12-29  1:06 ` with-url Stefan Monnier
2016-12-29  1:12   ` with-url Lars Ingebrigtsen
2016-12-29 16:05 ` with-url Eli Zaretskii
2016-12-29 16:35   ` with-url Lars Ingebrigtsen
2016-12-29 16:40     ` with-url Lars Ingebrigtsen
2016-12-29 16:58       ` with-url Eli Zaretskii
2016-12-29 18:52         ` with-url Lars Ingebrigtsen
2016-12-29 20:31           ` with-url Eli Zaretskii
2016-12-30 14:12             ` with-url Lars Ingebrigtsen
2016-12-30 15:23               ` with-url Lars Ingebrigtsen
2016-12-30 16:58               ` with-url Eli Zaretskii
2017-01-21 15:31         ` with-url Lars Ingebrigtsen
2017-01-21 15:33           ` with-url Lars Ingebrigtsen
2017-01-21 15:54           ` with-url Eli Zaretskii
2017-01-21 16:32             ` with-url Lars Ingebrigtsen
2017-01-21 16:40               ` with-url Eli Zaretskii
2017-01-22 15:55                 ` with-url Lars Ingebrigtsen
2017-01-22 16:39                   ` with-url Eli Zaretskii
2016-12-29 16:53     ` with-url Eli Zaretskii
2016-12-29 18:48       ` with-url Lars Ingebrigtsen
2017-01-01  1:07 ` with-url Dmitry Gutov
2017-01-03 17:47   ` with-url Stefan Monnier
2017-01-26 23:00     ` with-url Ted Zlatanov
2017-01-26 23:08       ` with-url Lars Ingebrigtsen
2017-01-27 13:49         ` with-url Ted Zlatanov
2017-01-21 15:44   ` with-url Lars Ingebrigtsen
2017-01-21 20:26     ` Dmitry Gutov [this message]
2017-01-21 20:32       ` with-url Lars Ingebrigtsen
2017-01-21 20:36         ` with-url Dmitry Gutov
2017-01-21 20:49           ` with-url Lars Ingebrigtsen
2017-01-21 21:05             ` with-url Dmitry Gutov
2017-01-21 21:12               ` with-url Lars Ingebrigtsen
2017-01-21 21:16                 ` with-url Dmitry Gutov
2017-01-21 21:23                   ` with-url Lars Ingebrigtsen
2017-01-21 21:27                     ` with-url Dmitry Gutov
2017-01-21 21:37                       ` with-url Lars Ingebrigtsen
2017-01-21 21:54                         ` with-url Dmitry Gutov
2017-01-21 22:07                           ` with-url Lars Ingebrigtsen
2017-01-22 12:14                             ` with-url Yuri Khan
2017-01-22 14:46                               ` with-url Lars Ingebrigtsen
2017-01-22 15:13                                 ` with-url Dmitry Gutov
2017-01-22 16:36                                   ` with-url Eli Zaretskii
2017-01-22 21:27                                     ` with-url Dmitry Gutov
2017-01-22 14:22                             ` with-url Dmitry Gutov
2017-01-22 14:42                               ` with-url Lars Ingebrigtsen
2017-01-21 20:34       ` with-url Lars Ingebrigtsen
2017-01-21 20:38         ` with-url Dmitry Gutov
2017-01-21 20:48           ` with-url Lars Ingebrigtsen
2017-01-21 22:25       ` with-url John Mastro
2017-01-22 16:04 ` with-url Lars Ingebrigtsen
2017-01-22 16:42   ` with-url Eli Zaretskii
2017-01-22 16:55     ` with-url Lars Ingebrigtsen
2017-01-22 23:56   ` not with-url Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e6b14926-f56c-55b0-3d7f-388fda9580ac@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=emacs-devel@gnu.org \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.