Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Error Message for throwSqlError() #905

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
7 changes: 6 additions & 1 deletion iModelJsNodeAddon/JsInteropDgnDb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,12 @@ 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
);
// throwSqlError(rc);

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