emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: James Powell <powellj@pdx.edu>
To: emacs-orgmode@gnu.org
Subject: bug: Error handling in source blocks.
Date: Mon, 9 Aug 2021 21:13:37 -0700	[thread overview]
Message-ID: <3ac06f2a-c14b-593f-a6e2-8e1c85c19436@pdx.edu> (raw)

   Error handling is important and hard to get right.  Me, I prefer to
   treat every warning as an error (-Werror in gcc, "options(warn=2)" in
   R, etc).  I want the system to grind to a halt at the least sign of
   trouble.

   When I write some nonsense into a code block as in this example:

   ,----
   | : This next code block is intended to trigger an error, because that
   | : variable "fffff838293483" with that attribute/member "x8483848"
   | : probably does not exist.
   | :
   | : #+begin_src R :exports both
   | : x <- fffff838293483$x8483848
   | : #+end_src
   | :
   | : #+RESULTS:
   | :
   | : #+begin_src R :exports both :results table :colnames yes
   | : require(tidyverse)
   | : tribble(~a, ~b, 1, 2)
   | : #+end_src
   | :
   | : #+RESULTS:
   | : | a | b |
   | : |---+---|
   | : | 1 | 2 |
   | : #+end_src
   `----


   which does trigger an error in R
   ,----
   | Error: object 'fffff838293483' not found
   | [traceback follows]
   `----


   and I do org-to-PDF export, I would like the PDF to be not built and
   loud alarm bells to ring bringing the error to my attention.

   What happens instead: the document builds from org into PDF with no
   indication that anything went wrong at all, except perhaps minor bits
   of missing or incorrect text in the PDF file.  The error can easily be
   buried in the output as more and later source blocks from the same
   document are evaluated.

   Likewise, in 'sh',
   ,----
   | #+begin_src sh :exports results
   | exit 1
   | #+end_src
   `----


   Sh exits 1 to indicate an error, so I would like this to ring alarm
   bells and fail to produce a PDF on org-to-PDF export.

   We might add examples in Java, Python, C++, C along the same lines.
   All of these should be in a unit test (because error handling is 
important).
   There do not seem to be any unit tests that exercise error handling in
   org-9.4.4.

   Exceptions that are thrown in the block should also at least
   optionally always and reliably abort the org-to-PDX export and ring
   alarm bells.

   I would like to see a section in the org manual called "Error handling
   in source blocks" that discusses the issue.

   I searched for "error handling" at <https://lists.gnu.org/archive>,
   with no results that are relevant.

   thank you for your time,
   - JP

-- 
James E. Powell, MS
Pronouns: he/him/his
Applied Physics PhD Candidate
Department of Physics
Portland State University
Home page: http://web.pdx.edu/~powellj
Office: SRTC 409B Phone: +1-503-725-8515



             reply	other threads:[~2021-08-10  4:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-10  4:13 James Powell [this message]
2021-08-10 19:42 ` bug: Error handling in source blocks Berry, Charles via General discussions about Org-mode.
2021-08-10 20:30 ` Tim Cross
2021-08-10 23:14   ` Tom Gillespie
2021-08-11  6:23   ` tomas

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.orgmode.org/

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

  git send-email \
    --in-reply-to=3ac06f2a-c14b-593f-a6e2-8e1c85c19436@pdx.edu \
    --to=powellj@pdx.edu \
    --cc=emacs-orgmode@gnu.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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).