From 4a8b52ea08bb5cf501cd20bce4744ae6c7edd9b1 Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Wed, 17 Sep 2014 08:56:59 -0300 Subject: 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 --- src/nvim/api/private/helpers.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/nvim/api/private/helpers.h') diff --git a/src/nvim/api/private/helpers.h b/src/nvim/api/private/helpers.h index f3ecdaacc4..f29deb53f9 100644 --- a/src/nvim/api/private/helpers.h +++ b/src/nvim/api/private/helpers.h @@ -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 -- cgit