Skip to content

Commit fc3a35b

Browse files
committed
chore: Improve error logging format in napi_fatal_error function
1 parent 966b23a commit fc3a35b

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

packages/host/cpp/RuntimeNodeApi.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,16 @@ void napi_fatal_error(const char* location,
127127
size_t location_len,
128128
const char* message,
129129
size_t message_len) {
130-
log_error("Fatal error in Node-API: %.*s: %.*s",
131-
static_cast<int>(location_len),
132-
location,
133-
static_cast<int>(message_len),
134-
message);
130+
if (location && location_len) {
131+
log_error("Fatal Node-API error: %.*s %.*s",
132+
static_cast<int>(location_len),
133+
location,
134+
static_cast<int>(message_len),
135+
message);
136+
} else {
137+
log_error(
138+
"Fatal Node-API error: %.*s", static_cast<int>(message_len), message);
139+
}
135140
abort();
136141
}
137142

0 commit comments

Comments
 (0)