api/msgpack-rpc: Improve error infrastructure

- Add error type information to `Error`
- Rename `set_api_error` to `api_set_error` for consistency with other api_*
  functions/macros.
- Refactor the api_set_error macro to accept formatted strings and error types
- Improve error messages
- Wrap error messages with gettext macro
- Refactor msgpack-rpc serialization to transform Error instances into [type,
  message] arrays
- Add error type information to API metadata
- Normalize nvim->client and client->nvim error handling(change
  channel_send_call to accept an Error pointer instead of the `errored` boolean
  pointer)
- Use macro to initialize Error structures
This commit is contained in:
Thiago de Arruda
2014-09-17 08:56:59 -03:00
parent 67a16384a4
commit 4a8b52ea08
11 changed files with 201 additions and 146 deletions

View File

@@ -8,10 +8,13 @@
#include "nvim/memory.h"
#include "nvim/lib/kvec.h"
#define set_api_error(message, err) \
do { \
xstrlcpy(err->msg, message, sizeof(err->msg)); \
err->set = true; \
#define api_set_error(err, errtype, ...) \
do { \
snprintf((err)->msg, \
sizeof((err)->msg), \
__VA_ARGS__); \
(err)->set = true; \
(err)->type = kErrorType##errtype; \
} while (0)
#define OBJECT_OBJ(o) o