From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Zelphir Kaltstahl Newsgroups: gmane.lisp.guile.user Subject: Exception handling - symbol for encoding exception type? Date: Tue, 8 Mar 2022 17:11:26 +0000 Message-ID: <18366d41-ee52-9122-997e-cd18b04ece3f@posteo.de> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32722"; mail-complaints-to="usenet@ciao.gmane.io" To: guile-user Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Tue Mar 08 18:15:19 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 1nRdQd-0008JB-Gh for guile-user@m.gmane-mx.org; Tue, 08 Mar 2022 18:15:19 +0100 Original-Received: from localhost ([::1]:48920 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRdQa-0003wB-R5 for guile-user@m.gmane-mx.org; Tue, 08 Mar 2022 12:15:17 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:48616) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRdN1-0001Fl-2P for guile-user@gnu.org; Tue, 08 Mar 2022 12:11:37 -0500 Original-Received: from mout02.posteo.de ([185.67.36.66]:60383) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRdMx-0007qL-Ry for guile-user@gnu.org; Tue, 08 Mar 2022 12:11:34 -0500 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id BD605240103 for ; Tue, 8 Mar 2022 18:11:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1646759487; bh=ozyGkZS1EbhfrWr+Bcq9mdbKtjiOlMwmgyZhW0IzKKI=; h=Date:To:From:Subject:From; b=sKEJlDyOScDH5ru/H7BBvtFKbIA5iraNmXIlc4Hkn0R7D1RQf+LCWEFFH0RbKRtTa Big2P7lJJ1bCPwOCroOY/E7Ry1rwmeaRR2yTAERCw5VR/nWP8rSmpEgo/HINlvjHQE teu+oKxdxzoxWTxP0BvoVJ9XAw3k0KQu7oRUpGDei9Nd1nOFiFj2HtrgWHU7eEx0GS DLXFdCY8nck6I1mhTZXkSnHyRmjUTCvzsdCsNb03g3IX1KxrbV52pPgScKLvWc/6Ad tO/0DX4FuTAkpWsbarE2rcdwnBAEaucp9lf/UtO2KGR++XbCrSG0aN5RllYHF3igcG 9ilfwBo+jdhAQ== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4KChgg1bmGz6tmT for ; Tue, 8 Mar 2022 18:11:26 +0100 (CET) Content-Language: en-US Received-SPF: pass client-ip=185.67.36.66; envelope-from=zelphirkaltstahl@posteo.de; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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:18162 Archived-At: Hello Guile users! I have a question about exception handling. Lets say I have some code raising some exception: ~~~~ (import (ice-9 exceptions)) (define something-causing-an-exception   (λ ()     (raise-exception      (make-exception       (make-non-continuable-error)       (make-exception-with-message "Some error message.")       (make-exception-with-irritants (list whatever is responsible for causing an error))       (make-exception-with-origin 'name-of-procedure))))) (with-exception-handler     (λ (exception)       ;; handling the exception       ...)   (λ ()     (something-causing-an-exception))   #:unwind? #t) ~~~~ On https://www.gnu.org/software/guile/manual/html_node/Exception-Objects.html I can see a hierarchy of exception types: ~~~~ &exception |- &warning |- &message |- &irritants |- &origin \- &error    |- &external-error    \- &programming-error       |- &assertion-failure       |- &non-continuable       |- &implementation-restriction       |- &lexical       |- &syntax       \- &undefined-variable ~~~~ 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 guess I am looking for a way to specify a symbol and later, when an exception happens, check for a symbol, to know what the reason for the exception is, instead of searching around in a &message string, which feels a bit messy. I think in some other languages this would be encoded in the type or class or the exception itself. One would catch only exceptions of a specific type. This is a convention inside the code, which does not necessarily spread to other programs or code bases. Best regards, Zelphir -- repositories: https://notabug.org/ZelphirKaltstahl