unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Vivien Kraus <vivien@planete-kraus.eu>
To: Zelphir Kaltstahl <zelphirkaltstahl@posteo.de>,
	guile-user <guile-user@gnu.org>
Subject: Re: Exception handling - symbol for encoding exception type?
Date: Tue, 08 Mar 2022 18:48:52 +0100	[thread overview]
Message-ID: <ceaf6454bf27e3c6a1442d4934461fc3d172149a.camel@planete-kraus.eu> (raw)
In-Reply-To: <18366d41-ee52-9122-997e-cd18b04ece3f@posteo.de>

[-- Attachment #1: Type: text/plain, Size: 1465 bytes --]

Hello Zelphir,

Le mardi 08 mars 2022 à 17:11 +0000, Zelphir Kaltstahl a écrit :
> Is the idea, that one should rely merely on the existing
> exception types, which are:
> 
> + assertion-failure
> + non-continuable
> + implementation-restriction
> + lexical
> + syntax
> + undefined-variable
> 
> and that one should not try to create additional types? Or
> is the idea to encode more specifics into the &message?
I’m a big fan of the new exceptions, but I had the same question at
first. I tried some code that put everything into the message, I tried
some more code where every possible exception had its type and
contained its parameters, and at the end I settled on this rule of
thumb: if you’re doing something in your code and an exception might be
raised, catch it and raise it again with an additional message
(internationalize it please). If your program needs to perform more
tasks, such as banning the user that raised the exception, create a new
exception type with as few parameters as necessary (most of mine have
none), and raise an occurence of it as well as the internationalized
message. You can use make-exception to create an exception composed of
a new message and an existing exception, and no information will be
lost.

More generally, don’t bother with a new exception type until you need
it to do something useful.

Of course, this is my opinion, others may view the problem differently.

Vivien

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 695 bytes --]

  reply	other threads:[~2022-03-08 17:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-08 17:11 Exception handling - symbol for encoding exception type? Zelphir Kaltstahl
2022-03-08 17:48 ` Vivien Kraus [this message]
2022-03-08 18:18 ` Maxime Devos
2022-03-08 18:20 ` Maxime Devos
2022-04-07 21:39   ` Zelphir Kaltstahl
2022-03-08 18:22 ` Maxime Devos
2022-03-08 19:07 ` Olivier Dion via General Guile related discussions

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

  List information: https://www.gnu.org/software/guile/

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

  git send-email \
    --in-reply-to=ceaf6454bf27e3c6a1442d4934461fc3d172149a.camel@planete-kraus.eu \
    --to=vivien@planete-kraus.eu \
    --cc=guile-user@gnu.org \
    --cc=zelphirkaltstahl@posteo.de \
    /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.
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 read-only IMAP folder(s) and NNTP newsgroup(s).