Refactor(typescript)/error handling (#1283)

* actually display error if it occurs while instantiating

* bump version
This commit is contained in:
Jacob Nguyen 2023-07-26 22:06:16 -05:00 committed by GitHub
parent 9100b2ef6f
commit 0e866a0e8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View File

@ -58,10 +58,13 @@ Napi::Function NodeModelWrapper::GetClass(Napi::Env env) {
} }
} }
llmodel_set_implementation_search_path(library_path.c_str()); llmodel_set_implementation_search_path(library_path.c_str());
llmodel_error* e = nullptr; llmodel_error e = {
inference_ = std::make_shared<llmodel_model>(llmodel_model_create2(full_weight_path.c_str(), "auto", e)); .message="looks good to me",
if(e != nullptr) { .code=0,
Napi::Error::New(env, e->message).ThrowAsJavaScriptException(); };
inference_ = std::make_shared<llmodel_model>(llmodel_model_create2(full_weight_path.c_str(), "auto", &e));
if(e.code != 0) {
Napi::Error::New(env, e.message).ThrowAsJavaScriptException();
return; return;
} }
if(GetInference() == nullptr) { if(GetInference() == nullptr) {

View File

@ -1,6 +1,6 @@
{ {
"name": "gpt4all", "name": "gpt4all",
"version": "2.1.0-alpha", "version": "2.1.1-alpha",
"packageManager": "yarn@3.6.1", "packageManager": "yarn@3.6.1",
"main": "src/gpt4all.js", "main": "src/gpt4all.js",
"repository": "nomic-ai/gpt4all", "repository": "nomic-ai/gpt4all",