Subject: bug#75065: Upon archive download failure print the original error

From: Stefan Monnier <[email-masked]>
Date: Thu, 26 Dec 2024 15:40:21 -0500

> The `car` seems to just contain word error. Here's how both compare:
>
> • current patch with `(cdr err)`:
>     Failed to download ‘melpa’ archive. Error: ("Location melpa.org/packages/ is not a url nor an absolute file name")
>
> • suggested change with `err`:
>     Failed to download ‘melpa’ archive. Error: (error "Location melpa.org/packages/ is not a url nor an absolute file name")
>
> I can of course remove the word `Error` in the second case.
> My question then is: will `(car err)` always be the word "error"? Or
> may there be another content?

The shape and content of `err` depends on the actual error that caused
the download to fail.  `(car err)` contains the error "type", which can
be `error` but can also be more specific such as
`wrong-number-of-arguments`, `file-error`, ...

>> > It seems harmless, I am just uncertain if we should prefer %S or %s
>> > to format the error message.
>>
>> `%s` to print `err` or `(cdr err)` would be wrong, since `%s` is for
>> use with strings rather than lists.  IOW, IMO, it should be either
>>
>>     ...%S" ... err)
>>
>> or
>>
>>     ...%s" ... (error-message-string err))
>>
>> where the first is a bit more "debugging/developer" friendly and the
>> second is a bit more "user" friendly.
>
> In my tests there seems to be no difference in the output between %s
> and %S.

Try (format "%S" '(a "b")) vs (format "%s" '(a "b"))

> I would presume doing `(message "%s" '(a b))` would result in
> error as the param isn't a string, but it works.

I agree that in an ideal world it should signal an error, but here
we are.

        Stefan