From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Newsgroups: gmane.emacs.devel Subject: Re: Attaching context info to an error Date: Wed, 27 Dec 2023 18:28:49 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13952"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Dec 27 19:29:35 2023 Return-path: Envelope-to: ged-emacs-devel@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 1rIYet-0003T0-5M for ged-emacs-devel@m.gmane-mx.org; Wed, 27 Dec 2023 19:29:35 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rIYeP-00026p-T8; Wed, 27 Dec 2023 13:29:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rIYeO-00026O-L6 for emacs-devel@gnu.org; Wed, 27 Dec 2023 13:29:04 -0500 Original-Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rIYeM-0008L5-Pl for emacs-devel@gnu.org; Wed, 27 Dec 2023 13:29:04 -0500 Original-Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2ccc6e509c8so20667481fa.0 for ; Wed, 27 Dec 2023 10:29:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703701741; x=1704306541; darn=gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=X+p+sUDTsOoJ5nIyLPeT7IfaYoIDp7Hc3nKmYH4y98Y=; b=Q31ra4AxP4atb3fen+eKHm7whHSBsIDV5d+qFHl9Xij9byDnnLl+6wVg9N6O3Zkre6 nN92eQc0vy1SESoxyPrinZWqSehPEgnaEUzH19wnnFJ23zKoxWtSoDwPCPt6l8syMaxr NIvB4FzynZoJOG24YN8w1hcfXPCcopajhrX+86EASdutqLpgqR3xwk3btr4gAT+FSt0o LPDum41WQxyZmOPDT0cPWPkMsws6wglVY9Go2Ezo5/VKhuW8G3AX/UxqrTDb3lhHMAC6 7dfGnBYFP5+EQ4QTKVY9uGCPuX8owQJCzztzPwuiIFafSJOTH4uqJpwTnmHjrUXXQimR gv/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703701741; x=1704306541; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=X+p+sUDTsOoJ5nIyLPeT7IfaYoIDp7Hc3nKmYH4y98Y=; b=QpzldTUpbmzBVgB+NqmnnTGnySzl34agcYlKDa0/glzXfjB3fRkjP+zq7tqasM3CoF AhxDUsTpH6stC92DaQ1oeDeXJerCTKVGbi4/lfkCelsEU4RRxGKbAyuun1VEEK2q/bV/ mkjT2UBT3Wc2baanTnIvmGoNxHrG2KNzYWx37cecl0lp3OZmoUf1WXp4PGIihk1r0gQy jYVvjcZyZTHUdBFkYUlAVOezojgw9ZXRlgYCsu+oC3iUKQsPMBdcccGjE53iVsuvomdH 8s7EkiTOHqVECxCSUyLitFo0l+mcQ/KD6pjFvV8wYbyPTkxPPQWvb28YlKsFC+dxNsqc Hnew== X-Gm-Message-State: AOJu0Yxj3Fvy5jSaTan7lmDEwti/B6rOZtP4QSFntGUwlOFjJXJWvhBP rN4HAayR4YxJK3QJCZaJBpet6TkspdGgkczDt34= X-Google-Smtp-Source: AGHT+IGO9DfQyngzAk3g9Ch/pIRV9USYeA62M4mpzXabE+FTIrlG2JXKA3hQuLv36qt8oYxHyzbK507YjGrKkMqrQB8= X-Received: by 2002:a2e:9e4b:0:b0:2cc:83a6:1268 with SMTP id g11-20020a2e9e4b000000b002cc83a61268mr5471898ljk.10.1703701740776; Wed, 27 Dec 2023 10:29:00 -0800 (PST) In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::22f; envelope-from=joaotavora@gmail.com; helo=mail-lj1-x22f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:314254 Archived-At: On Wed, Dec 27, 2023 at 6:08=E2=80=AFPM Jo=C3=A3o T=C3=A1vora wrote: > > Could you give some concrete examples of things you'd (be able to) do > > with it? > Just look at anyCL program that uses conditions, there are > very many of them. One of them is Snooze [1] which uses them > to represent HTTP error codes. To elaborate a little more, Snooze is (I think) a good example of how 'handler-bind' and 'restart-case' can cooperate to allow different modes of operation for a HTTP server (or HTTP REST router, which is what Snooze really is). You may want to catch or not catch error conditions, catch or not catch HTTP conditions, debug these conditions in your Lisp (or via Emacs with SLY/SLIME), explain these conditions to the HTTP client verbosely (in developement environments) , succinctly (in production environments), muffle them, log them, etc. The file https://github.com/joaotavora/snooze/blob/master/common.lisp contains the meat and bones of this logic, and https://github.com/joaotavora/snooze/blob/master/api.lisp contains a reasonably well docstring'ed description of the interface to these facilities. See the docstrings of *catch-http-conditions* and *catch-errors*. Restarts like 'explain-verbosely' and 'explain-succinctly' are shown to the user when the debugger is popped. During development the user can thus interactively control what gets sent to the client (usually a web-browser in another window). Unattended operation of such a server is achieved by automatically invoking these restarts from handler-bind handlers. Jo=C3=A3o