#1799 new defect

Document how to distinguish exceptions from JSON, or encode exceptions as JSON

Reported by: davidsarah Owned by:
Priority: normal Milestone: undecided
Component: code-frontend-web Version: 1.9.2
Keywords: json usability docs Cc: darrob
Launchpad Bug:

Description (last modified by davidsarah)

darrob: hello again. i have a python program that runs tahoe repair operations using urllib and parses tahoe's json responses. this works very well except for one thing: if a file is gone and i attempt a repair, the resulting NotEnoughSharesError? is not presented as json data but plaintext (a check without repair responds in json, however).

darrob: am i missing something on tahoe's side that i can do about it? if not, are there other error messages like this that i should be aware of before i adapt the program?

We need to document how to distinguish exceptions (I *think* valid JSON always starts with a "{" or "[" character).

An alternative would be to encode the exception as JSON (i.e. something like {"exception": "..."}), although that would make it more difficult to read. Since these APIs are mainly for programmatic use, that might be acceptible.

Change History (4)

comment:1 Changed at 2012-08-31T15:06:29Z by davidsarah

  • Description modified (diff)

comment:2 Changed at 2012-08-31T15:43:26Z by warner

hm, yeah, we should probably make a rule that t=json means that the response is *always* in JSON, and find a way to express exceptions in JSON like you said.

comment:3 Changed at 2012-08-31T17:13:19Z by zooko

+1

comment:4 Changed at 2012-08-31T21:16:33Z by davidsarah

+1, and we should also document in webapi.rst the first version in which that applies.

Note: See TracTickets for help on using tickets.