unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#19768: json.el: end-of-file errors untrappable
@ 2015-02-04 13:59 era eriksson
  2015-02-04 15:34 ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: era eriksson @ 2015-02-04 13:59 UTC (permalink / raw)
  To: 19768; +Cc: era+emacs

Package: emacs
Version: 24.3.1
X-Debbugs-Cc: era+emacs@iki.fi

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.





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#19768: json.el: end-of-file errors untrappable
  2015-02-04 13:59 bug#19768: json.el: end-of-file errors untrappable era eriksson
@ 2015-02-04 15:34 ` Stefan Monnier
  2015-02-05 11:51   ` era eriksson
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2015-02-04 15:34 UTC (permalink / raw)
  To: era eriksson; +Cc: 19768, era+emacs

> I'm not sure what the proper fix should be.  Maybe these occurrences
> could be changed to json-end-of-file or something?

That sounds right.  If we define json-end-of-file as an error which as
`end-of-file' as parent, it should give us the best of both worlds.


        Stefan





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#19768: json.el: end-of-file errors untrappable
  2015-02-04 15:34 ` Stefan Monnier
@ 2015-02-05 11:51   ` era eriksson
  2015-02-05 19:52     ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: era eriksson @ 2015-02-05 11:51 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 19768

On Wed, Feb 4, 2015, at 17:34, Stefan Monnier wrote:
> > I'm not sure what the proper fix should be.  Maybe these occurrences
> > could be changed to json-end-of-file or something?
> 
> That sounds right.  If we define json-end-of-file as an error which as
> `end-of-file' as parent, it should give us the best of both worlds.

https://github.com/tripleee/emacs/tree/bug19768 contains a simple patch
which implements this, but I am uncertain how to test it.  Also, I am
having second thoughts about defining the new error symbol as a child of
'end-of-file when all the other error symbols neatly inherit from
'json-error.  Anyway, feel free to review and/or pull and/or ignore. (-:

/* era */

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





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#19768: json.el: end-of-file errors untrappable
  2015-02-05 11:51   ` era eriksson
@ 2015-02-05 19:52     ` Stefan Monnier
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2015-02-05 19:52 UTC (permalink / raw)
  To: era eriksson; +Cc: 19768-done

> https://github.com/tripleee/emacs/tree/bug19768 contains a simple patch
> which implements this, but I am uncertain how to test it.  Also, I am
> having second thoughts about defining the new error symbol as a child of
> 'end-of-file when all the other error symbols neatly inherit from
> 'json-error.  Anyway, feel free to review and/or pull and/or ignore. (-:

Installed, making it inherit from both kinds of errors ;-)


        Stefan





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-02-05 19:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-04 13:59 bug#19768: json.el: end-of-file errors untrappable era eriksson
2015-02-04 15:34 ` Stefan Monnier
2015-02-05 11:51   ` era eriksson
2015-02-05 19:52     ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).