Skip to content

Commit

Permalink
feat: add support for reasons on assertion failure (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
edusperoni authored Jul 16, 2022
1 parent 4a78e1e commit e185014
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion NativeScript/runtime/Helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const std::string GetCurrentScriptUrl(v8::Isolate* isolate);

bool LiveSync(v8::Isolate* isolate);

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

}

Expand Down
5 changes: 4 additions & 1 deletion NativeScript/runtime/Helpers.mm
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@
return true;
}

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

if (isolate == nullptr) {
Log(@"====== Assertion failed ======");
if(!reason.empty()) {
Log(@"Reason: %s", reason.c_str());
}
Log(@"Native stack trace:");
LogBacktrace();
assert(false);
Expand Down

0 comments on commit e185014

Please sign in to comment.