emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug: Error handling in source blocks.


From: James Powell
Subject: bug: Error handling in source blocks.
Date: Mon, 9 Aug 2021 21:13:37 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0

  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 via email to

[Prev in Thread] Current Thread [Next in Thread]