Skip to content

Commit e185014

Browse files
authored
feat: add support for reasons on assertion failure (#172)
1 parent 4a78e1e commit e185014

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

NativeScript/runtime/Helpers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const std::string GetCurrentScriptUrl(v8::Isolate* isolate);
6565

6666
bool LiveSync(v8::Isolate* isolate);
6767

68-
void Assert(bool condition, v8::Isolate* isolate = nullptr);
68+
void Assert(bool condition, v8::Isolate* isolate = nullptr, std::string const &reason = std::string());
6969

7070
}
7171

NativeScript/runtime/Helpers.mm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@
657657
return true;
658658
}
659659

660-
void tns::Assert(bool condition, Isolate* isolate) {
660+
void tns::Assert(bool condition, Isolate* isolate, std::string const &reason) {
661661
if (!RuntimeConfig.IsDebug) {
662662
assert(condition);
663663
return;
@@ -676,6 +676,9 @@
676676

677677
if (isolate == nullptr) {
678678
Log(@"====== Assertion failed ======");
679+
if(!reason.empty()) {
680+
Log(@"Reason: %s", reason.c_str());
681+
}
679682
Log(@"Native stack trace:");
680683
LogBacktrace();
681684
assert(false);

0 commit comments

Comments
 (0)