From 066a7e60cad248e534c22aacdb7c0433eec7f140 Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Tue, 20 Jun 2017 17:00:41 +0100 Subject: [PATCH] Handle a failure to get the joke --- dad-joke.el | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dad-joke.el b/dad-joke.el index adbfc4c..e5a7eae 100644 --- a/dad-joke.el +++ b/dad-joke.el @@ -43,9 +43,11 @@ If INSERT is non-nil the joke will be inserted into the current buffer rather than shown in the minibuffer." (interactive "P") (let ((joke (dad-joke-get))) - (if insert - (insert joke) - (message joke)))) + (if (and joke (not (zerop (length joke)))) + (if insert + (insert joke) + (message joke)) + (error "I didn't get the joke! :-(")))) (provide 'dad-joke)