aboutsummaryrefslogtreecommitdiff
path: root/src/error.cpp
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2024-05-05 16:48:12 +0100
committerGitHub <noreply@github.com>2024-05-05 16:48:12 +0100
commit1e5267c8e7ab1777e6691d28b4cf84f62c5e1871 (patch)
tree5b08122e583a0058891336b7994f3a6ec9cb6250 /src/error.cpp
parent96a4cecee5f77438b62199fd0ca64de20753b143 (diff)
parentee818304f360d67f28726f907eed2df38c1c8ea9 (diff)
Merge pull request #3532 from laytan/fix-invalid-json
fix invalid JSON when an error does not have a position
Diffstat (limited to 'src/error.cpp')
-rw-r--r--src/error.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/error.cpp b/src/error.cpp
index 1ad757964..1009bb7cd 100644
--- a/src/error.cpp
+++ b/src/error.cpp
@@ -728,9 +728,8 @@ gb_internal void print_all_errors(void) {
}
res = gb_string_append_fmt(res, "\",\n");
- res = gb_string_append_fmt(res, "\t\t\t\"pos\": {\n");
-
if (ev.pos.file_id) {
+ res = gb_string_append_fmt(res, "\t\t\t\"pos\": {\n");
res = gb_string_append_fmt(res, "\t\t\t\t\"file\": \"");
String file = get_file_path_string(ev.pos.file_id);
for (isize k = 0; k < file.len; k++) {
@@ -743,6 +742,8 @@ gb_internal void print_all_errors(void) {
i32 end_column = gb_max(ev.end.column, ev.pos.column);
res = gb_string_append_fmt(res, "\t\t\t\t\"end_column\": %d\n", end_column);
res = gb_string_append_fmt(res, "\t\t\t},\n");
+ } else {
+ res = gb_string_append_fmt(res, "\t\t\t\"pos\": null,\n");
}
res = gb_string_append_fmt(res, "\t\t\t\"msgs\": [\n");