Skip to content

Commit 9cb6a20

Browse files
committed
Guard know code paths in error handling
Improves reported error message by a lot
1 parent dad3022 commit 9cb6a20

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/sass_context.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ extern "C" {
105105
json_append_member(json_err, "message", json_mkstring(e.what()));
106106
json_append_member(json_err, "formatted", json_mkstring(msg_stream.str().c_str()));
107107

108-
c_ctx->error_json = json_stringify(json_err, " ");;
108+
try { c_ctx->error_json = json_stringify(json_err, " "); } catch(...) {}
109109
c_ctx->error_message = sass_copy_c_string(msg_stream.str().c_str());
110110
c_ctx->error_text = sass_copy_c_string(e.what());
111111
c_ctx->error_status = 1;
@@ -124,7 +124,7 @@ extern "C" {
124124
json_append_member(json_err, "status", json_mknumber(2));
125125
json_append_member(json_err, "message", json_mkstring(ba.what()));
126126
json_append_member(json_err, "formatted", json_mkstring(msg_stream.str().c_str()));
127-
c_ctx->error_json = json_stringify(json_err, " ");;
127+
try { c_ctx->error_json = json_stringify(json_err, " "); } catch(...) {}
128128
c_ctx->error_message = sass_copy_c_string(msg_stream.str().c_str());
129129
c_ctx->error_text = sass_copy_c_string(ba.what());
130130
c_ctx->error_status = 2;
@@ -139,7 +139,7 @@ extern "C" {
139139
json_append_member(json_err, "status", json_mknumber(3));
140140
json_append_member(json_err, "message", json_mkstring(e.what()));
141141
json_append_member(json_err, "formatted", json_mkstring(msg_stream.str().c_str()));
142-
c_ctx->error_json = json_stringify(json_err, " ");;
142+
try { c_ctx->error_json = json_stringify(json_err, " "); } catch(...) {}
143143
c_ctx->error_message = sass_copy_c_string(msg_stream.str().c_str());
144144
c_ctx->error_text = sass_copy_c_string(e.what());
145145
c_ctx->error_status = 3;
@@ -154,7 +154,7 @@ extern "C" {
154154
json_append_member(json_err, "status", json_mknumber(4));
155155
json_append_member(json_err, "message", json_mkstring(e.c_str()));
156156
json_append_member(json_err, "formatted", json_mkstring(msg_stream.str().c_str()));
157-
c_ctx->error_json = json_stringify(json_err, " ");;
157+
try { c_ctx->error_json = json_stringify(json_err, " "); } catch(...) {}
158158
c_ctx->error_message = sass_copy_c_string(msg_stream.str().c_str());
159159
c_ctx->error_text = sass_copy_c_string(e.c_str());
160160
c_ctx->error_status = 4;
@@ -169,7 +169,7 @@ extern "C" {
169169
json_append_member(json_err, "status", json_mknumber(4));
170170
json_append_member(json_err, "message", json_mkstring(e));
171171
json_append_member(json_err, "formatted", json_mkstring(msg_stream.str().c_str()));
172-
c_ctx->error_json = json_stringify(json_err, " ");;
172+
try { c_ctx->error_json = json_stringify(json_err, " "); } catch(...) {}
173173
c_ctx->error_message = sass_copy_c_string(msg_stream.str().c_str());
174174
c_ctx->error_text = sass_copy_c_string(e);
175175
c_ctx->error_status = 4;
@@ -183,7 +183,7 @@ extern "C" {
183183
msg_stream << "Unknown error occurred" << std::endl;
184184
json_append_member(json_err, "status", json_mknumber(5));
185185
json_append_member(json_err, "message", json_mkstring("unknown"));
186-
c_ctx->error_json = json_stringify(json_err, " ");;
186+
try { c_ctx->error_json = json_stringify(json_err, " "); } catch(...) {}
187187
c_ctx->error_message = sass_copy_c_string(msg_stream.str().c_str());
188188
c_ctx->error_text = sass_copy_c_string("unknown");
189189
c_ctx->error_status = 5;

0 commit comments

Comments
 (0)