Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle errors of code blocks and return them to the user #86

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

KaiHa
Copy link

@KaiHa KaiHa commented Jan 16, 2022

During the execution of code-blocks some errors could go unnoticed. This PR adds code that will return an error description to the user. With this the following code blocks should return error messages instead of silently failing:

#+BEGIN_SRC emacs-lisp :async
(error "somewhere an error was signaled")
#+END_SRC
#+begin_src sh :results output :async
echo something went wrong >&2
false
#+end_src
#+begin_src python :async
raise NotImplementedError
#+end_src

See the individual commits for details.

And thanks for this awesome package.

During the execution of code blocks an error could be signaled.  The
consequence of this would be that the FINISH-FUNC will not be called.
Therefore handle the error in the START-FUNC and return a textual
representation of it instead of the result.

A code block like the following

```
  #+begin_src emacs-lisp :async
  (error "somewhere an error was signaled")
  #end_src
```

would no longer lead to a #+result that gets never updated and keeps
the UUID forever.  Instead the following would be put as the result:

  Failure: during the async execution of your code block the following error was signaled:
    error: (somewhere an error was signaled)
At least shell and python source code blocks could fail without any
possibility to notice it.  Therefore adding an advice to
org-babel-eval-error-notify that will set the variable
ob-async-eval-error in the case of an error.  If this variable is set,
return the error.

With this the following code blocks should produce a result that
gives a hint about the error:

```
  #+begin_src sh :results output :async
  echo something went wrong >&2
  false
  #+end_src
```

```
  #+begin_src python :async
  raise NotImplementedError
  #+end_src
```
@KaiHa KaiHa changed the title Handle signals of code-blocks by returning an error as the result Handle error of code blocks and return them to the user Jan 16, 2022
@KaiHa KaiHa changed the title Handle error of code blocks and return them to the user Handle errors of code blocks and return them to the user Jan 16, 2022
@KaiHa
Copy link
Author

KaiHa commented Jan 16, 2022

This should also fix #81.

@chasecaleb
Copy link

I would love to see this merged!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants