Skip to content

Commit

Permalink
Handle signals of code-blocks by returning an error as the result
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
KaiHa committed Jan 16, 2022
1 parent 9aac486 commit 14c1afe
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ob-async.el
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,12 @@ block."
(let ((default-directory ,default-directory))
(with-temp-buffer
(insert org-babel-async-content)
(,cmd ,body ',params))))
(condition-case context
(,cmd ,body ',params)
(error (format
"Failure: during the async execution of your code block the following error was signaled:\n %s: %s"
(car context)
(cdr context)))))))
`(lambda (result)
(with-current-buffer ,(current-buffer)
(let ((default-directory ,default-directory))
Expand Down

0 comments on commit 14c1afe

Please sign in to comment.