-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjs_error.c
More file actions
49 lines (43 loc) · 1.67 KB
/
js_error.c
File metadata and controls
49 lines (43 loc) · 1.67 KB
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
#include "js.h"
char *strstatus(Status s) {
switch (s) {
case OK: return "OK";
case ERROR_outofmemory: return "out of memory";
case ERROR_script_internal: return "script internal error";
case ERROR_script_unrecognized_function: return "script unrecognized function";
case ERROR_tcperror: return "tcperror";
case ERROR_bsonformat: return "bsonformat";
case ERROR_notobject_or_array: return "not object or array";
case ERROR_mathdomain: return "outside math domain";
case ERROR_endoffile: return "end of file";
case ERROR_doesnot_exist: return "does not exist";
case ERROR_script_parse: return "script parse";
case ERROR_json_parse: return "json parse";
case ERROR_not_document: return "not document";
case ERROR_not_found: return "not found";
case ERROR_toomany_local_docstores: return "too many docStores";
case ERROR_txn_being_committed: return "txn being committed";
case ERROR_no_visible_version: return "no visible version";
case ERROR_write_conflict: return "write conflict";
case ERROR_key_constraint_violation:return "key constraint violation";
case ERROR_not_operator_int: return "Invalid iterator seek operation";
case ERROR_not_key: return "not key value";
default:;
}
return NULL;
}
void errorText(Status s) {
char *status = strstatus(s);
if (!s)
printf("Status: OK\n");
else if (status)
printf("Error: %s\n", status);
else
printf("Unrecognized error: %d", s);
}
value_t makeError(Node *node, environment_t *env, char *msg) {
value_t v;
fprintf (stderr, "js error %s line = %d, node id = %d type = %d: %s\n", env->first->script, (int)node->lineNo, (int)(node - env->table), (int)node->type, msg);
v.bits = vt_control;
return v;
}