blob: 425da998bc48a0abd53090040ca3636a313dc3fb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include "api/helpers.h"
#include "api/defs.h"
#include "../vim.h"
void try_start()
{
++trylevel;
}
bool try_end(Error *err)
{
--trylevel;
// Without this it stops processing all subsequent VimL commands and
// generates strange error messages if I e.g. try calling Test() in a
// cycle
did_emsg = false;
if (got_int) {
const char msg[] = "Keyboard interrupt";
if (did_throw) {
// If we got an interrupt, discard the current exception
discard_current_exception();
}
strncpy(err->msg, msg, sizeof(err->msg));
err->set = true;
got_int = false;
} else if (msg_list != NULL && *msg_list != NULL) {
int should_free;
char *msg = (char *)get_exception_string(*msg_list,
ET_ERROR,
NULL,
&should_free);
strncpy(err->msg, msg, sizeof(err->msg));
err->set = true;
free_global_msglist();
if (should_free) {
free(msg);
}
} else if (did_throw) {
strncpy(err->msg, (char *)current_exception->value, sizeof(err->msg));
err->set = true;
}
return err->set;
}
|