Skip to content

Commit

Permalink
Improve Error Message for throwSqlError() (#905)
Browse files Browse the repository at this point in the history
* wip use BeSQLiteLib functions

* Use GetLogError

* use throwSqlResult and use GetLogError

* fix tab

* clean up and remove comment

---------

Co-authored-by: Daniel Rodriguez <DanRod1999@users.noreply.github.com>
Co-authored-by: affank <khanaffan@gmail.com>
Co-authored-by: Arun George <11051042+aruniverse@users.noreply.github.com>
  • Loading branch information
4 people authored Nov 15, 2024
1 parent eae3dd7 commit f0435be
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion iModelJsNodeAddon/IModelJsNative.h
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ ENUM_IS_FLAGS(TextEmphasis);

struct JsInterop {
[[noreturn]] static void throwSqlResult(Utf8CP msg, Utf8CP fileName, DbResult result) {
BeNapi::ThrowJsException(Env(), Utf8PrintfString("%s [%s]: %s", msg, fileName, BeSQLiteLib::GetErrorString(result)).c_str(), result);
BeNapi::ThrowJsException(Env(), Utf8PrintfString("%s [%s]: rc=%d, %s", msg, fileName, (int)result, BeSQLiteLib::GetLogError(result).c_str()).c_str(), result);
}
[[noreturn]] static void throwDgnDbStatus(DgnDbStatus);
[[noreturn]] static void throwWrongClass() { throwDgnDbStatus(DgnDbStatus::WrongClass); }
Expand Down
2 changes: 1 addition & 1 deletion iModelJsNodeAddon/JsInteropDgnDb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ Napi::String JsInterop::InsertLinkTableRelationship(DgnDbR dgndb, Napi::Object o
BeSQLite::EC::ECInstanceKey relKey;
auto rc = dgndb.InsertLinkTableRelationship(relKey, *relClass, sourceId, targetId, props.get()); // nullptr is okay if there are no props
if (BE_SQLITE_OK != rc)
throwSqlError();
JsInterop::throwSqlResult("Failed to insert relationship", dgndb.GetDbFileName(), rc);

return Napi::String::New(Env(), relKey.GetInstanceId().ToHexStr());
}
Expand Down

0 comments on commit f0435be

Please sign in to comment.