From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Vivien Kraus Newsgroups: gmane.lisp.guile.user Subject: Re: Exception handling - symbol for encoding exception type? Date: Tue, 08 Mar 2022 18:48:52 +0100 Message-ID: References: <18366d41-ee52-9122-997e-cd18b04ece3f@posteo.de> Mime-Version: 1.0 Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-x4ZrfRa5/9onxTZvecz/" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14290"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Evolution 3.42.1 To: Zelphir Kaltstahl , guile-user Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Tue Mar 08 18:49:44 2022 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nRdxw-0003Vb-6j for guile-user@m.gmane-mx.org; Tue, 08 Mar 2022 18:49:44 +0100 Original-Received: from localhost ([::1]:42364 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRdxu-00049z-VT for guile-user@m.gmane-mx.org; Tue, 08 Mar 2022 12:49:42 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:57948) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRdxT-00048W-8W for guile-user@gnu.org; Tue, 08 Mar 2022 12:49:20 -0500 Original-Received: from [2a00:5881:4008:2810::309] (port=37892 helo=planete-kraus.eu) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim 4.90_1) (envelope-from ) id 1nRdxR-0005sJ-7N for guile-user@gnu.org; Tue, 08 Mar 2022 12:49:14 -0500 Original-Received: from planete-kraus.eu (localhost.lan [127.0.0.1]) by planete-kraus.eu (OpenSMTPD) with ESMTP id 8b3b4543; Tue, 8 Mar 2022 17:49:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=planete-kraus.eu; h= message-id:subject:from:to:date:in-reply-to:references :content-type:mime-version; s=dkim; bh=Jz2RuWpVbtB8w9+o4Uel21DlW xQ=; b=LTZFcreLChVyGvKQgWjHQW/zYX+SUlsTl3CI3r+c5W182x/a/oEh8CKbp wBcDGG0pOlIbdgW2JyvjhHWC++16h+UrKGejq8Gfv67nAHgNYwyVuyHFai2x3S77 JAtP6mceQsyoqHyjD4nraXwqbbOU/mDn1WzpqUxELohWeq/yz0= Original-Received: by planete-kraus.eu (OpenSMTPD) with ESMTPSA id 222f03f0 (TLSv1.3:AEAD-CHACHA20-POLY1305-SHA256:256:NO); Tue, 8 Mar 2022 17:49:01 +0000 (UTC) In-Reply-To: <18366d41-ee52-9122-997e-cd18b04ece3f@posteo.de> X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:5881:4008:2810::309 (failed) Received-SPF: pass client-ip=2a00:5881:4008:2810::309; envelope-from=vivien@planete-kraus.eu; helo=planete-kraus.eu X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.io gmane.lisp.guile.user:18163 Archived-At: --=-x4ZrfRa5/9onxTZvecz/ Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello Zelphir, Le mardi 08 mars 2022 =C3=A0 17:11 +0000, Zelphir Kaltstahl a =C3=A9crit=C2= =A0: > Is the idea, that one should rely merely on the existing > exception types, which are: >=20 > + assertion-failure > + non-continuable > + implementation-restriction > + lexical > + syntax > + undefined-variable >=20 > and that one should not try to create additional types? Or > is the idea to encode more specifics into the &message? I=E2=80=99m 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=E2=80=99re doing something in your code and an exception migh= t 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=E2=80=99t bother with a new exception type until you ne= ed it to do something useful. Of course, this is my opinion, others may view the problem differently. Vivien --=-x4ZrfRa5/9onxTZvecz/ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQHMBAABCAA2FiEEq4yIHjMvkliPpwQnO7C8EjLYuCwFAmInlwQYHHZpdmllbkBw bGFuZXRlLWtyYXVzLmV1AAoJEDuwvBIy2LgsckUMAMdEFFryJ1sucMrXdr0SHh7M 80WWvLiAb3ZgHSyLAyfWT+OI5NVTj3fWuowZDY5obkNhDAPlwtBsjDnCq2MzDBFs vEfR4H1B3zffftUwJhqfbNW404Z1N7tP5ukym4Mq8km1TCyA5fBpgGlX98BCCAPA DegYvcBskFkd74UeX7mvWep1nxPbHWLHR+qX3mMkEC9z1QSafVN1XTksTzof0MYh bRqUkeDpnyccwskZshVE4BG154ysBnM9yfsZbnHPbMuKyj2hlYWF+/PvSVOC9Hp2 oJxisEUnuG0YWVDvRoG0trP4X9qhR/mmueEv4k4UBZOfykPSFbxEZnYMkcB4Jdm4 qQ9h7Ahw/dKjF9PNC+cHEkZPqQc9nRy0eMGwozh3Eos800a8+dWX3bvKE+ijaw9L fqWHrpZpDHstZjdRYxHwMY/3+qiwUUDfJp2kFtsyTULS1pDHl/hejdw2oo27VKAf CkbDU97sFNrwrEC2h+muirYxPL4J8Rzef740Oa2m3g== =J2zS -----END PGP SIGNATURE----- --=-x4ZrfRa5/9onxTZvecz/--