aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/window.c
diff options
context:
space:
mode:
authorThiago de Arruda <tpadilha84@gmail.com>2014-09-17 08:56:59 -0300
committerThiago de Arruda <tpadilha84@gmail.com>2014-09-18 21:30:31 -0300
commit4a8b52ea08bb5cf501cd20bce4744ae6c7edd9b1 (patch)
treec7d53772706ed78bee255100b328db11e3dc867e /src/nvim/api/window.c
parent67a16384a46c5eb51ba43d9150e95a1742cffbde (diff)
downloadrneovim-4a8b52ea08bb5cf501cd20bce4744ae6c7edd9b1.tar.gz
rneovim-4a8b52ea08bb5cf501cd20bce4744ae6c7edd9b1.tar.bz2
rneovim-4a8b52ea08bb5cf501cd20bce4744ae6c7edd9b1.zip
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
Diffstat (limited to 'src/nvim/api/window.c')
-rw-r--r--src/nvim/api/window.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/nvim/api/window.c b/src/nvim/api/window.c
index dd256f2b6d..751518424b 100644
--- a/src/nvim/api/window.c
+++ b/src/nvim/api/window.c
@@ -57,7 +57,9 @@ void window_set_cursor(Window window, ArrayOf(Integer, 2) pos, Error *err)
if (pos.size != 2 || pos.items[0].type != kObjectTypeInteger ||
pos.items[1].type != kObjectTypeInteger) {
- set_api_error("\"pos\" argument must be a [row, col] array", err);
+ api_set_error(err,
+ Validation,
+ _("Argument \"pos\" must be a [row, col] array"));
return;
}
@@ -69,12 +71,12 @@ void window_set_cursor(Window window, ArrayOf(Integer, 2) pos, Error *err)
int64_t col = pos.items[1].data.integer;
if (row <= 0 || row > win->w_buffer->b_ml.ml_line_count) {
- set_api_error("cursor position outside buffer", err);
+ api_set_error(err, Validation, _("Cursor position outside buffer"));
return;
}
if (col > MAXCOL || col < 0) {
- set_api_error("Column value outside range", err);
+ api_set_error(err, Validation, _("Column value outside range"));
return;
}
@@ -117,7 +119,7 @@ void window_set_height(Window window, Integer height, Error *err)
}
if (height > INT_MAX || height < INT_MIN) {
- set_api_error("Height value outside range", err);
+ api_set_error(err, Validation, _("Height value outside range"));
return;
}
@@ -160,7 +162,7 @@ void window_set_width(Window window, Integer width, Error *err)
}
if (width > INT_MAX || width < INT_MIN) {
- set_api_error("Width value outside range", err);
+ api_set_error(err, Validation, _("Width value outside range"));
return;
}
@@ -283,7 +285,7 @@ Tabpage window_get_tabpage(Window window, Error *err)
/// @return true if the window is valid, false otherwise
Boolean window_is_valid(Window window)
{
- Error stub = {.set = false};
+ Error stub = ERROR_INIT;
return find_window_by_handle(window, &stub) != NULL;
}