RAPI: format error messages as JSON
authorIustin Pop <iustin@google.com>
Fri, 13 Feb 2009 11:38:26 +0000 (11:38 +0000)
committerIustin Pop <iustin@google.com>
Fri, 13 Feb 2009 11:38:26 +0000 (11:38 +0000)
commit1f8588f6691bae503f7deb3e07278f1df8f48b00
treec21c71a6d71636f1f0958363855d6c4622bb3a97
parent77e1d7539ba6642a394fd689860e49bb4f9c1a61
RAPI: format error messages as JSON

This patch changes the format of the HTTP error messages from text/html, which
is hard to parse from RAPI clients, to JSON which can be automatically parsed.

The error message is an object, which contains always three keys:
  - code, an integer with the error code
  - message, a short description
  - explain, holding (if available) a description of the error

In order to implement this, there is a bit of change to the http server
and executor classes. I've tested and the error handling still works
(but less optimal, no error message) in case the error formatting itself
raises an exception.

Reviewed-by: imsnah
daemons/ganeti-rapi
lib/http/server.py