Subject: json.el: end-of-file errors untrappable
From: era eriksson <[email-masked]>
To: [email-masked]
Date: Wed, 04 Feb 2015 15:59:43 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Package: emacs
Version: 24.3.1
X-Debbugs-Cc: [email-masked]

The code in json.el uses (signal 'end-of-file) in many scenarios. 
Unfortunately, the default value of debug-ignore-errors causes these
errors to bypass any error checking, and unhelpfully land in the
*Messages* buffer with little indication as to what went wrong or which
code path caused this message.

Once you know this, debugging json-read is easy; but the fix is
unobvious, and might have unintended side effects.

Steps to repro:

    (require 'json)
    (setq debug-on-error t)
    (json-read-from-string "")

Expected result:

*Backtrace* showing where something went wrong

Actual result:

json-read: End of file during parsing

(The "json-read:" prefix is not visible in the minibuffer message for
me, but it lands in the *Messages* buffer.)

Workaround:

    (let (debug-ignore-errors)
      (json-read-from-string ""))

I'm not sure what the proper fix should be.  Maybe these occurrences
could be changed to json-end-of-file or something?  Or maybe json-read
could include the 'let' form from the workaround.

See also:
http://stackoverflow.com/questions/28317081/debug-on-error-vs-debug-on-signal-in-json-el-in-particular

/* era */

-- 
If this were a real .signature, it would suck less.  Well, maybe not.