mirror of
https://github.com/neovim/neovim.git
synced 2025-10-17 15:21:47 +00:00
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:
@@ -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
|
||||
|
Reference in New Issue
Block a user