The webpage that is shown to the user when zabbix is unable to connect to the database is also returned when you make a call to the API while the database is down.
This causes problems as instead of getting JSON you are suddenly getting HTML to parse.
This is the text on the website:
pg_connect() [<a href='function.pg-connect'>function.pg-connect</a>]: Unable to connect to PostgreSQL server: could not connect to server: Connection refused
Is the server running on host "localhost" and accepting
TCP/IP connections on port 5432? [include/db.inc.php:99]
Constant ZBX_PAGE_NO_MENU already defined [warning.php:29]
Zabbix 2.0.2
Zabbix is temporarily unavailable!
This is not good. The API should return an error that can easily be parsed, just like the rest of them. Preferrably it would be best if the API started defining its own error codes as the JSONRPC v2 standard says you should.
http://www.jsonrpc.org/specification#error_object
I do not know if this is fixed in a later version, but I noticed the problem when I suddenly got an error in the simple API client I have created for node.js https://github.com/flexd/zabbix.js
Getting HTML when you expect to parse JSON and no errors were returned is not good